Build it step by step
0 of 8 doneMake the picture
Draw a 60 pixel high image and save as 24-bit BMP.
Prepare the card
Format FAT32 and copy IMG.BMP to it.
Set the boost module
Adjust to 5.0 V with a meter.
Wire the strip and the SD module
Connect as in the table.
Upload
The serial monitor should not show an error.
Test indoors
Press the button and watch the columns play.
Take a long exposure
Use a tripod and a 5 to 10 second exposure.
Tune the speed
Adjust COLUMN_MS and your walking pace.
How do you build a light painting wand?
A stick of LEDs plays an image one column at a time, so a long-exposure photo shows the picture floating in the air. You need ESP32 DevKit V1, WS2812B strip 5 m (30 LEDs/m), MicroSD Card Module, SanDisk microSD card 32 GB (A1, Class 10), Li-Po battery 3.7 V 2000 mAh, MT3608 Boost Module and Tactile push button 6 mm. It takes 8 steps and about 180 minutes.
- Level
- Intermediate
- Time
- About 180 min
- Parts
- 7
Wiring
| From | To | Why |
|---|---|---|
| Li-po + | MT3608 IN+ | Battery power, protected cell with a switch |
| Li-po - | MT3608 IN- | Ground |
| MT3608 OUT+ | Strip + and ESP32 VIN | Set to 5.0 V with a meter before connecting anything |
| MT3608 OUT- | Strip - and ESP32 GND | Common ground |
| ESP32 GPIO5 | 330 Ω resistor then strip DIN | Data line |
| SD module VCC | ESP32 3V3 | Power, use a 3.3 V module |
| SD module GND | ESP32 GND | Ground |
| SD module CS, SCK, MISO, MOSI | ESP32 GPIO15, GPIO18, GPIO19, GPIO23 | SPI |
| Button | ESP32 GPIO4 and GND | Start the image |
Code
Make a picture exactly 60 pixels high in any image editor, save it as a 24-bit BMP named IMG.BMP on a FAT32 card, and keep it up to 200 pixels wide. The sketch loads it into memory, so the wand plays each column in turn at a fixed rate when you press the button. Put the camera on a tripod in a dark place with a long exposure (several seconds), hold the wand upright and walk at an even speed in front of the lens; a slower walk makes a wider picture. Adjust COLUMN_MS and your speed until the picture looks right. The boost module must be set to 5.0 V with a meter before connecting the ESP32 or strip. Use a protected Li-po with a switch, charge it with a proper charger and never leave it charging unattended. Arduino IDE with the ESP32 boards package, board "ESP32 Dev Module".
Runs on a virtual ESP32 Dev Module 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).
// Libraries: Adafruit NeoPixel, SD (built in). Plays /IMG.BMP: 24-bit BMP, exactly 60 pixels high, up to 200 wide.
#include <SPI.h>
#include <SD.h>
#include <Adafruit_NeoPixel.h>
const int LEDS = 60;
const byte DATA_PIN = 5, BTN = 4, CS = 15;
const int COLUMN_MS = 4; // milliseconds per column, adjust to your walking speed
Adafruit_NeoPixel strip(LEDS, DATA_PIN, NEO_GRB + NEO_KHZ800);
uint8_t *pixels = nullptr; // width * 60 * 3 bytes
int width = 0;
bool loadBMP(const char *path) {
File f = SD.open(path);
if (!f) return false;
uint8_t h[54];
f.read(h, 54);
uint32_t offset = h[10] | (h[11] << 8) | (h[12] << 16) | (h[13] << 24);
int32_t w = h[18] | (h[19] << 8) | (h[20] << 16) | (h[21] << 24);
int32_t ht = h[22] | (h[23] << 8) | (h[24] << 16) | (h[25] << 24);
if (h[28] != 24 || ht != LEDS || w < 1 || w > 200) { f.close(); return false; }
width = w;
pixels = (uint8_t*)malloc(width * LEDS * 3);
int rowSize = ((width * 3 + 3) / 4) * 4; // BMP rows are padded to 4 bytes
uint8_t *row = (uint8_t*)malloc(rowSize);
for (int y = 0; y < LEDS; y++) { // row 0 in the file is the bottom of the picture
f.seek(offset + (uint32_t)y * rowSize);
f.read(row, rowSize);
for (int x = 0; x < width; x++) {
uint8_t b = row[x * 3], g = row[x * 3 + 1], r = row[x * 3 + 2]; // BMP stores blue, green, red
int i = (x * LEDS + y) * 3;
pixels[i] = r; pixels[i + 1] = g; pixels[i + 2] = b;
}
}
free(row); f.close();
return true;
}
void setup() {
Serial.begin(115200);
pinMode(BTN, INPUT_PULLUP);
strip.begin(); strip.setBrightness(40); strip.show(); // low brightness suits long exposures and saves the battery
if (!SD.begin(CS) || !loadBMP("/IMG.BMP")) { Serial.println("Could not load /IMG.BMP"); strip.setPixelColor(0, strip.Color(80, 0, 0)); strip.show(); }
}
void loop() {
if (width && digitalRead(BTN) == LOW) {
delay(1500); // time to start walking
for (int x = 0; x < width; x++) {
for (int y = 0; y < LEDS; y++) { int i = (x * LEDS + y) * 3; strip.setPixelColor(y, pixels[i], pixels[i + 1], pixels[i + 2]); }
strip.show();
delay(COLUMN_MS);
}
strip.clear(); 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 |
|---|---|
| IMG.BMP present | No error message |
| Button pressed | Picture plays column by column |
| Even walking speed | Picture looks undistorted in the photo |
| Wrong file size | Red first pixel and an error message |
If it does not work
Could not load
Check the file is 24-bit, 60 pixels high and under 200 wide.
Colours wrong
The BMP order is blue, green, red; the code swaps it, so check the file type.
Picture mirrored
Reverse the loop or walk the other way.
Battery drains fast
Lower the brightness.
Still stuck? Find the fault step by step with your multimeter →
Common questions
What parts do I need for the light painting wand?
ESP32 DevKit V1, WS2812B strip 5 m (30 LEDs/m), MicroSD Card Module, SanDisk microSD card 32 GB (A1, Class 10), Li-Po battery 3.7 V 2000 mAh, MT3608 Boost Module and Tactile push button 6 mm. WS2812B strip 5 m (30 LEDs/m): Cut 60 LEDs.
How long does the light painting wand take to build?
About 180 minutes for a intermediate maker, in 8 steps.
How do I know the light painting wand works?
IMG.BMP present: No error message. Button pressed: Picture plays column by column. Even walking speed: Picture looks undistorted in the photo.
Could not load: what should I check?
Check the file is 24-bit, 60 pixels high and under 200 wide.
Colours wrong: what should I check?
The BMP order is blue, green, red; the code swaps it, so check the file type.
Picture mirrored: what should I check?
Reverse the loop or walk the other way.
Battery drains fast: what should I check?
Lower the brightness.
