Build it step by step
0 of 7 doneWire the LEDs
Each long leg through 220 ohms to D2 up to D9, all short legs to GND.
Arrange the LEDs
In a straight line on the stick, LED 1 at the top.
Wire the tilt switch
D10 to GND.
Upload the sketch
The LEDs stay off.
Wave the wand side to side in the dark
The letters appear in the air.
Tune COLUMN_US
Smaller for a fast wave, larger for a slow wave.
Fix the Nano and a power bank to the stick
So it works without the computer.
How do you build a persistence-of-vision wand?
Eight LEDs on a stick flash a column of a message each fraction of a second, so when the wand is waved the message appears hanging in the air. A tilt switch starts the display. You need Arduino Nano, LED 5 mm red × 8, Resistor 220 Ω × 8, Tilt sensor (ball switch, SW-520D), Jumper wires male to male (40 pcs, 20 cm) and Breadboard 830 Tie Points. It takes 7 steps and about 150 minutes.
- Level
- Beginner
- Time
- About 150 min
- Parts
- 6
Parts list
- Development BoardsBuyArduino Nano × 1
- SemiconductorsBuyLED 5 mm red × 8
- PassivesBuyResistor 220 Ω × 8
- SensorsBuy
- PrototypingBuy
- PrototypingBuy
Tick what you already own. It saves to My Garage, so “Build with what I have” knows.
Wiring
| From | To | Why |
|---|---|---|
| LED 1 (top) long leg | 220 ohm resistor to Nano D2 | Top row of the letters |
| LED 2 long leg | 220 ohm resistor to Nano D3 | Row 2 |
| LED 3 long leg | 220 ohm resistor to Nano D4 | Row 3 |
| LED 4 long leg | 220 ohm resistor to Nano D5 | Row 4 |
| LED 5 long leg | 220 ohm resistor to Nano D6 | Row 5 |
| LED 6 long leg | 220 ohm resistor to Nano D7 | Row 6 |
| LED 7 long leg | 220 ohm resistor to Nano D8 | Row 7 |
| LED 8 (bottom) long leg | 220 ohm resistor to Nano D9 | Spare row |
| All LED short legs | Nano GND | Common return |
| Tilt switch | Nano D10 and GND | Starts the message when the wand moves |
Code
Persistence of vision means the eye keeps an image for a fraction of a second after it has gone. If a row of LEDs flashes a different pattern each few thousandths of a second while it moves through the air, the patterns line up side by side in the eye, and a message seems to hang in space. Each letter is stored as five columns of seven dots, and the program sends each column to the eight LEDs in turn, with a short blank between letters. The tilt switch has a small ball inside that rolls when the wand is swung, and each time it changes state a new sweep of the message starts, with a short lockout so that it does not restart in the middle. The speed of your wave decides how wide the letters look, so change the column time until the letters are readable, smaller for a fast wave. Read the message in a dim room, and wave the wand in a clear space away from people and furniture. Make the wand from a light stick and do not make it heavy. Use only LEDs with a resistor each, never the LEDs directly on the pins. Add more letters to the font table, using the same five-byte format, for other words.
Runs on a virtual Arduino Nano 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).
const uint8_t LED_PINS[8] = { 2, 3, 4, 5, 6, 7, 8, 9 };
const int TILT = 10;
const unsigned int COLUMN_US = 2500; // time each column is lit: tune to your wave speed
const unsigned int GAP_US = 2500; // blank gap between letters
// 5 by 7 letters, one byte per column, bit 0 is the top row
struct Glyph { char ch; uint8_t col[5]; };
const Glyph FONT[] = {
{ 'A', { 0x7E, 0x11, 0x11, 0x11, 0x7E } },
{ 'C', { 0x3E, 0x41, 0x41, 0x41, 0x22 } },
{ 'E', { 0x7F, 0x49, 0x49, 0x49, 0x41 } },
{ 'K', { 0x7F, 0x08, 0x14, 0x22, 0x41 } },
{ 'L', { 0x7F, 0x40, 0x40, 0x40, 0x40 } },
{ 'O', { 0x3E, 0x41, 0x41, 0x41, 0x3E } },
{ 'R', { 0x7F, 0x09, 0x19, 0x29, 0x46 } },
{ 'T', { 0x01, 0x01, 0x7F, 0x01, 0x01 } },
};
const char MESSAGE[] = "ELECTROLARK"; // use only letters that are in FONT
bool lastTilt;
unsigned long lockoutUntil = 0;
void showColumn(uint8_t bits) {
for (int i = 0; i < 8; i++) digitalWrite(LED_PINS[i], (bits >> i) & 1);
}
const Glyph* find(char c) {
for (unsigned int i = 0; i < sizeof(FONT) / sizeof(FONT[0]); i++)
if (FONT[i].ch == c) return &FONT[i];
return nullptr;
}
void playMessage() {
for (const char* p = MESSAGE; *p; p++) {
const Glyph* g = find(*p);
if (g) {
for (int c = 0; c < 5; c++) {
showColumn(g->col[c]);
delayMicroseconds(COLUMN_US);
}
}
showColumn(0);
delayMicroseconds(GAP_US);
}
showColumn(0);
}
void setup() {
for (int i = 0; i < 8; i++) pinMode(LED_PINS[i], OUTPUT);
pinMode(TILT, INPUT_PULLUP);
lastTilt = digitalRead(TILT);
showColumn(0);
}
void loop() {
bool t = digitalRead(TILT);
if (t != lastTilt && millis() > lockoutUntil) { // the ball moved: a sweep has started
playMessage();
lockoutUntil = millis() + 300; // ignore the rattle for a moment
}
lastTilt = t;
}Test checklist
What you should see at each check. If a reading is far off, stop and use the troubleshooting list.
| Check | Expected |
|---|---|
| Hold still | LEDs off |
| Shake gently | A burst of letters starts |
| Wave in a dim room | ELECTROLARK appears in the air |
| Wave faster | Letters look narrower |
| Change COLUMN_US | Letters change width |
If it does not work
Letters look mirrored
Wave the other way, or reverse the column order.
Nothing shows
Check the tilt switch wires and that it changes when shaken.
One LED dark
Check the leg direction and the resistor.
Letters upside down
Put LED 1 at the other end of the stick.
Restarts in the middle
Lengthen the lockout time.
Still stuck? Find the fault step by step with your multimeter →
Common questions
What parts do I need for the persistence-of-vision wand?
Arduino Nano, LED 5 mm red × 8, Resistor 220 Ω × 8, Tilt sensor (ball switch, SW-520D), Jumper wires male to male (40 pcs, 20 cm) and Breadboard 830 Tie Points.
How long does the persistence-of-vision wand take to build?
About 150 minutes for a beginner maker, in 7 steps.
How do I know the persistence-of-vision wand works?
Hold still: LEDs off. Shake gently: A burst of letters starts. Wave in a dim room: ELECTROLARK appears in the air.
Letters look mirrored: what should I check?
Wave the other way, or reverse the column order.
Nothing shows: what should I check?
Check the tilt switch wires and that it changes when shaken.
One LED dark: what should I check?
Check the leg direction and the resistor.
Letters upside down: what should I check?
Put LED 1 at the other end of the stick.
