Build it step by step
0 of 8 doneMake the tree
Cut a cardboard triangle and punch nine holes.
Wire the LEDs
Each through 220 ohm to D2 to D10, minus to a ground rail.
Wire the button and knob
Button D11 to GND, knob middle to A0.
Upload the sketch
The first pattern, a chase, runs.
Turn the knob
The speed changes.
Press the button
The next pattern starts.
Press it until the fifth
The LEDs fade in a ripple.
Edit a table
Add a frame of your own and reload.
How do you build a desk tree LED sequencer?
A set of LEDs on a cardboard tree blink in programmable patterns chosen with a button. You need Arduino Uno R3, LED 5 mm red × 3, LED 5 mm green × 3, LED 5 mm yellow × 3, Resistor 220 Ω × 9, Tactile push button 6 mm, Potentiometer 10 kΩ, Breadboard 830 Tie Points and Jumper wires male to male (40 pcs, 20 cm). It takes 8 steps and about 100 minutes.
- Level
- Beginner
- Time
- About 100 min
- Parts
- 9
Parts list
- Development BoardsBuyArduino Uno R3 × 1
- SemiconductorsBuyLED 5 mm red × 3
- SemiconductorsBuyLED 5 mm green × 3
- SemiconductorsBuyLED 5 mm yellow × 3
- PassivesBuyResistor 220 Ω × 9
- SwitchesBuy
- PassivesBuy
- PrototypingBuy
- PrototypingBuy
Tick what you already own. It saves to My Garage, so “Build with what I have” knows.
Wiring
| From | To | Why |
|---|---|---|
| Nine LEDs plus through 220 ohm each | Uno D2 to D10 | Bottom to top of the tree |
| All LED minus legs | Uno GND | Share the ground rail |
| Pattern button | Uno D11 to GND | Internal pull-up, cycles patterns |
| Speed knob middle leg | Uno A0 | Outer legs to 5V and GND |
Code
Each pattern is a table of frames, and each frame is a number whose binary bits say which LEDs are on: 0x155 is 1 0101 0101, every other LED. Storing patterns as data rather than code makes it easy to add your own, and a struct with a pointer and a length lets the main loop treat every table the same way. The loop shows one frame at a time using millis(), so the button and the speed knob stay responsive, and the knob sets the delay between frames from 40 to 600 milliseconds. The fifth mode uses analogWrite on the five PWM pins to fade in and out, with a squared curve so the fade looks even to the eye, and a delay per LED so the glow ripples up the tree. Nine LEDs at about 15 milliamps each is 135 milliamps if all are on, which is fine for USB power but more than the total the Uno pins should supply, so keep a few LEDs off in each frame or use the transistor trick for bigger trees. Build the tree from cardboard with nine holes.
Runs on a virtual Arduino Uno 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).
// Nine LEDs on pins 2 to 10. Bit 0 is the LED on pin 2.
// The PWM-capable pins are 3, 5, 6, 9 and 10, used for the breathing pattern.
const uint8_t LED[9] = {2, 3, 4, 5, 6, 7, 8, 9, 10};
const uint8_t PWM_LED[5] = {3, 5, 6, 9, 10};
const uint8_t BTN = 11;
// Frame tables: each number is one frame, one bit per LED.
const uint16_t CHASE[] = {0x001,0x002,0x004,0x008,0x010,0x020,0x040,0x080,0x100,0x080,0x040,0x020,0x010,0x008,0x004,0x002};
const uint16_t ALT[] = {0x155, 0x0AA}; // every other LED, then the rest
const uint16_t FILL[] = {0x001,0x003,0x007,0x00F,0x01F,0x03F,0x07F,0x0FF,0x1FF,0x000};
const uint16_t TWINKLE[] = {0x021,0x104,0x048,0x090,0x112,0x00C,0x1A0,0x042};
struct Pattern { const uint16_t* frames; uint8_t count; };
const Pattern PATTERNS[4] = {
{CHASE, sizeof(CHASE) / 2}, {ALT, sizeof(ALT) / 2},
{FILL, sizeof(FILL) / 2}, {TWINKLE, sizeof(TWINKLE) / 2}
};
const uint8_t MODES = 5; // four tables plus the breathing mode
uint8_t mode = 0;
uint8_t frame = 0;
unsigned long lastStep = 0;
bool lastBtn = HIGH;
void showFrame(uint16_t bits) {
for (uint8_t i = 0; i < 9; i++) digitalWrite(LED[i], (bits >> i) & 1);
}
void allOff() { showFrame(0); for (uint8_t i = 0; i < 5; i++) analogWrite(PWM_LED[i], 0); }
void setup() {
for (uint8_t i = 0; i < 9; i++) pinMode(LED[i], OUTPUT);
pinMode(BTN, INPUT_PULLUP);
}
void loop() {
bool b = digitalRead(BTN);
if (lastBtn == HIGH && b == LOW) { mode = (mode + 1) % MODES; frame = 0; allOff(); delay(30); }
lastBtn = b;
unsigned long stepMs = map(analogRead(A0), 0, 1023, 40, 600); // speed knob
if (mode < 4) {
if (millis() - lastStep >= stepMs) {
lastStep = millis();
showFrame(PATTERNS[mode].frames[frame]);
frame = (frame + 1) % PATTERNS[mode].count;
}
} else {
// Breathing: the five PWM LEDs fade in and out, each a little behind its neighbour.
float t = millis() / (float)(stepMs * 8);
for (uint8_t i = 0; i < 5; i++) {
float level = (sin(t * 6.283 - i * 0.7) + 1) / 2;
analogWrite(PWM_LED[i], (int)(level * level * 255));
}
}
}Test checklist
What you should see at each check. If a reading is far off, stop and use the troubleshooting list.
| Check | Expected |
|---|---|
| Chase pattern | One LED runs up and down |
| Alternate pattern | Odd and even LEDs swap |
| Fill pattern | The tree fills from the bottom, then clears |
| Twinkle pattern | Random-looking pairs flash |
| Breathing pattern | Five LEDs fade smoothly |
If it does not work
A LED never lights
Check its direction and its pin number in the table.
Patterns too fast to see
Turn the knob fully one way, or raise the 600 limit.
LEDs look dim in breathing
Only pins 3, 5, 6, 9 and 10 can fade.
Button skips patterns
Increase the 30 ms debounce.
Uno gets warm
Too many LEDs on at once, use fewer lit LEDs per frame.
Still stuck? Find the fault step by step with your multimeter →
Common questions
What parts do I need for the desk tree LED sequencer?
Arduino Uno R3, LED 5 mm red × 3, LED 5 mm green × 3, LED 5 mm yellow × 3, Resistor 220 Ω × 9, Tactile push button 6 mm, Potentiometer 10 kΩ, Breadboard 830 Tie Points and Jumper wires male to male (40 pcs, 20 cm).
How long does the desk tree LED sequencer take to build?
About 100 minutes for a beginner maker, in 8 steps.
How do I know the desk tree LED sequencer works?
Chase pattern: One LED runs up and down. Alternate pattern: Odd and even LEDs swap. Fill pattern: The tree fills from the bottom, then clears.
A LED never lights: what should I check?
Check its direction and its pin number in the table.
Patterns too fast to see: what should I check?
Turn the knob fully one way, or raise the 600 limit.
LEDs look dim in breathing: what should I check?
Only pins 3, 5, 6, 9 and 10 can fade.
Button skips patterns: what should I check?
Increase the 30 ms debounce.
