Build it step by step
0 of 7 donePlan the LED runs
Keep each segment short.
Test the strip on the bench
A simple colour sweep.
Add the microphone
Check the level on the serial plotter.
Set the gain
Quiet speech lights a few LEDs.
Sew the strip on
Use silicone wire and slack.
Pocket the board and bank
Keep them dry.
Test it with music
Adjust the brightness cap.
How do you build a sound-reactive LED costume?
LED strips sewn on a jacket pulse with music from a small microphone, powered by a power bank. You need Seeed XIAO RP2040, WS2812B strip 5 m (30 LEDs/m), MAX4466 microphone module, USB A to USB-C cable (data) and Resistor 330 Ω. It takes 7 steps and about 120 minutes.
- Level
- Beginner
- Time
- About 120 min
- Parts
- 5
Wiring
| From | To | Why |
|---|---|---|
| MAX4466 OUT | XIAO A0 (D0) | Microphone signal |
| MAX4466 VCC and GND | XIAO 3V3 and GND | Power (output sits at about half of 3.3 V) |
| Strip DIN | 330 ohm resistor to XIAO D1 | LED data |
| Strip 5V | XIAO 5V pin (comes from USB-C) | LED power |
| Strip GND | XIAO GND | Common ground |
| USB-C lead | Power bank | Power for everything |
Code
The microphone amplifier outputs a wave centred at about half of 3.3 V, so loudness is not the voltage itself but how far the wave swings. The sketch measures the lowest and highest readings over twenty milliseconds, turns the difference into a level, and lights that many LEDs, with a quick rise and a slow fall so it looks smooth and does not flicker. Set the little gain screw on the MAX4466 so quiet speech lights a few LEDs and loud music lights most, then tune the 400 in the code. Power: a metre of 30 LEDs can draw about 1.8 A at full white, more than many power banks give, so the sketch limits brightness to 60 out of 255. Use a power bank that can give at least 1 A. Sew the strip on with flexible silicone wire between segments, leave a little slack at joints, and keep the electronics in a pocket away from sweat. Fast flashing lights can trigger photosensitive epilepsy, so keep the smooth fade and do not add strobe effects. Do not wear it in rain, and do not put the bank against skin if it gets warm. Arduino IDE with the Raspberry Pi Pico / RP2040 board package, board "Seeed XIAO RP2040".
Runs on a virtual Seeed XIAO RP2040 in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).
// Sound-reactive costume LEDs: loudness sets how many LEDs light and their colour, with a smooth fade (no strobing).
// Library: Adafruit NeoPixel. Board: Seeed XIAO RP2040.
#include <Adafruit_NeoPixel.h>
const uint8_t STRIP_PIN = D1;
const int N_LEDS = 30; // a 1 m strip of 30 LEDs
Adafruit_NeoPixel strip(N_LEDS, STRIP_PIN, NEO_GRB + NEO_KHZ800);
float level = 0;
void setup() {
analogReadResolution(10);
strip.begin();
strip.setBrightness(60); // keeps power bank current low (about 0.5 A at most)
strip.show();
}
void loop() {
int lo = 1023, hi = 0;
unsigned long start = millis();
while (millis() - start < 20) { // 20 ms window finds the swing of the sound wave
int v = analogRead(A0);
if (v < lo) lo = v;
if (v > hi) hi = v;
}
float loud = (hi - lo) / 400.0; // adjust 400 to suit your microphone gain
if (loud > 1) loud = 1;
if (loud > level) level = level + (loud - level) * 0.5; else level = level * 0.92; // quick rise, slow fall
int lit = (int)(level * N_LEDS);
for (int i = 0; i < N_LEDS; i++) {
if (i < lit) strip.setPixelColor(i, strip.ColorHSV((uint16_t)(i * 65535L / N_LEDS * 0.6), 255, 255));
else strip.setPixelColor(i, 0);
}
strip.show();
}Test checklist
What you should see at each check. If a reading is far off, stop and use the troubleshooting list.
| Check | Expected |
|---|---|
| Silence | LEDs off or one lit |
| Music | Bar rises and falls smoothly |
| Brightness cap | Bank stays cool |
| Walking about | Joints and wires hold |
If it does not work
LEDs flicker
Check the common ground and the 330 ohm resistor.
Always full
Lower the gain screw or raise the 400.
Reboots on bass
The bank cannot give enough current; lower brightness.
Still stuck? Find the fault step by step with your multimeter →
Common questions
What parts do I need for the sound-reactive LED costume?
Seeed XIAO RP2040, WS2812B strip 5 m (30 LEDs/m), MAX4466 microphone module, USB A to USB-C cable (data) and Resistor 330 Ω. WS2812B strip 5 m (30 LEDs/m): Cut 1 m.
How long does the sound-reactive LED costume take to build?
About 120 minutes for a beginner maker, in 7 steps.
How do I know the sound-reactive LED costume works?
Silence: LEDs off or one lit. Music: Bar rises and falls smoothly. Brightness cap: Bank stays cool.
LEDs flicker: what should I check?
Check the common ground and the 330 ohm resistor.
Always full: what should I check?
Lower the gain screw or raise the 400.
Reboots on bass: what should I check?
The bank cannot give enough current; lower brightness.
