What you build
One circuit carries the whole course. Every lesson opens on the same wiring and changes only the sketch:
- The lights: a WS2812 strip of eight LEDs on pin 6. Each LED keeps the first 24 bits it hears and passes the rest along, so one data pin drives them all.
- The power: a one-cell LiPo, 3.7 V and 500 mAh, feeding the strip. Its + also goes to A0, so the sketch can read it.
- The sewn LED: a red LED driven from A3 through conductive thread, drawn as a 47 ohm resistor, then a 100 ohm resistor. A2 reads the far end of the thread.
- The triggers: an ADXL345 accelerometer on A4 and A5, and a KY-038 sound sensor whose DO comes into pin 2.
- The brain: an Arduino Nano, the Uno's chip on a board 45 x 18 mm.
How it works
LiPo power. One cell is 4.2 V full, about 3.7 V for most of its life and empty at 3.0 V. Each WS2812 holds three LEDs of up to 20 mA, so full white is 60 mA an LED: eight at full white plus the board is about 500 mA, and a 500 mAh cell lasts an hour. At 20 percent white the same strip draws 96 mA, and the cell lasts 4.3 hours. Under 3.5 V the sketches dim the strip to stretch what is left.
Charging safely. Charge a LiPo with a proper LiPo charger, such as a TP4056 board with protection. Never charge it unattended, never while it is inside the clothes, and never bend, puncture or squash a cell. A puffy cell goes to battery recycling.
Sewn circuits. Conductive thread is stainless steel or silver-coated nylon, and thin thread is tens of ohms a meter. The sketch reads both ends of the thread and works out the current with Ohm's law: about 18 mA, with nearly a volt lost in the thread. Three meters of thread cuts the current by about a third. Keep power runs short, double the strands, keep + and - runs apart, and seal every knot.
Motion. The ADXL345 is read register by register over I2C: 0xE5 from DEVID, 0x08 into POWER_CTL to start measuring, and 256 counts a g at full resolution. Lying still it reads 1 g on z. A shake is a fast change: more than 0.5 g of movement across the three axes in one 20 ms step.
Sound. The KY-038 has no amplifier, so it is a loud-noise detector. Pin 2 is interrupt 0; the interrupt sets a flag, and the sketch ignores the pin for 150 ms after each clap, because one clap is a burst of pulses. Two claps less than 600 ms apart switch modes.
Comfort and washing. The brightness is capped at 40 percent so LEDs stay cool on skin, the jacket sleeps after 20 seconds without moving, and a wash mode turns everything off. Before any wash, take the battery out. Seal solder joints and sewn LEDs, keep the board in a felt pocket, and leave slack in the thread where cloth stretches.
The course
Wearables and light-up clothing takes seven lessons:
- Tiny boards: the Nano, and eight LEDs on one data pin.
- LiPo power: a mAh budget for full white and dim, and charging safely.
- Sewn circuits: the resistance of conductive thread, measured.
- Motion triggers: an ADXL345 register by register, and a shake.
- Sound triggers: a clap on an interrupt, a lockout and a double clap.
- Comfort and washing: a brightness cap, sleep, and a wash mode.
- Project: a reactive jacket: every trigger, a battery saver, and your own looks.
Every step but the last is checked against the running circuit.