It thinks and runs the whole light show.
Arduino
The brain
timed show sequences
Run a timed light show sequence on a bar graph.

Pin connections
| Part 1 | Part 2 | |
|---|---|---|
Arduino pin 2 | → | LED bar graph A1 |
Arduino pin 3 | → | LED bar graph A2 |
Arduino pin 4 | → | LED bar graph A3 |
Arduino pin 5 | → | LED bar graph A4 |
Arduino pin 6 | → | LED bar graph A5 |
Arduino pin 7 | → | LED bar graph A6 |
Arduino pin 8 | → | LED bar graph A7 |
Arduino pin 9 | → | LED bar graph A8 |
Arduino pin 10 | → | LED bar graph A9 |
Arduino pin 11 | → | LED bar graph A10 |
LED bar graph C10 | → | Arduino GND |
Let's put on a light show!
Lights fill up, empty out, then flash all together — your own mini light show!
Stage lights and big signs play timed shows just like this!
The problem
One pattern is fun, but a real show puts several fun parts together in order.
Think of it like
It's like a little dance routine — step one, step two, then a big finish!
It thinks and runs the whole light show.
Arduino
The brain
Ten little lights in a line that put on the show.
LED bar graph
The row of lights
Part 1 — fill up
The lights turn on one by one, from left to right, until the whole row is glowing.
digitalWrite(FIRST_PIN + i, HIGH); delay(80);
Hold the full row
All the lights stay on together for a moment before the next part.
delay(500);
Part 2 — empty out
Now the lights turn off one by one, from right to left, until the row is dark.
digitalWrite(FIRST_PIN + i, LOW); delay(80);
Part 3 — flash together
All the lights flash on and off three times — that is the big finish!
allOn(); delay(150); allOff(); delay(150);
Rest, then do it again
A nice long rest, then loop() jumps back and plays the whole show again!
delay(800);
Then loop back to step 1
Follow these steps in order. Match the wires to the colors shown.
Place Arduino
Place the Arduino (uno) on the breadboard.
Arduino placed — ready to build!
Place LED bar graph
Place the LED bar graph (bar1) on the breadboard.
Connect Arduino pin 2 to LED bar graph (bar1) A1
Connect Arduino pin 2 to LED bar graph (bar1) A1.
Connect Arduino pin 3 to LED bar graph (bar1) A2
Connect Arduino pin 3 to LED bar graph (bar1) A2.
Connect Arduino pin 4 to LED bar graph (bar1) A3
Connect Arduino pin 4 to LED bar graph (bar1) A3.
Connect Arduino pin 5 to LED bar graph (bar1) A4
Connect Arduino pin 5 to LED bar graph (bar1) A4.
Connect Arduino pin 6 to LED bar graph (bar1) A5
Connect Arduino pin 6 to LED bar graph (bar1) A5.
Connect Arduino pin 7 to LED bar graph (bar1) A6
Connect Arduino pin 7 to LED bar graph (bar1) A6.
Connect Arduino pin 8 to LED bar graph (bar1) A7
Connect Arduino pin 8 to LED bar graph (bar1) A7.
Connect Arduino pin 9 to LED bar graph (bar1) A8
Connect Arduino pin 9 to LED bar graph (bar1) A8.
Connect Arduino pin 10 to LED bar graph (bar1) A9
Connect Arduino pin 10 to LED bar graph (bar1) A9.
Connect Arduino pin 11 to LED bar graph (bar1) A10
Connect Arduino pin 11 to LED bar graph (bar1) A10.
Connect LED bar graph (bar1) C10 to Arduino GND
Connect LED bar graph (bar1) C10 to Arduino GND.
The all-on and all-off helpers
void allOff() {
for (int i = 0; i < NUM_LEDS; i++) {
digitalWrite(FIRST_PIN + i, LOW);
}
}
void allOn() {
for (int i = 0; i < NUM_LEDS; i++) {
digitalWrite(FIRST_PIN + i, HIGH);
}
}allOff() and allOn() use loops to switch all ten lights at once, so we don't write ten lines by hand.
Get all the lights ready
void setup() {
for (int i = 0; i < NUM_LEDS; i++) {
pinMode(FIRST_PIN + i, OUTPUT);
}
}setup() gets every light pin ready, one after another, so they can all glow.
The whole show
void loop() {
for (int i = 0; i < NUM_LEDS; i++) {
digitalWrite(FIRST_PIN + i, HIGH);
delay(80);
}
delay(500);
for (int i = NUM_LEDS - 1; i >= 0; i--) {
digitalWrite(FIRST_PIN + i, LOW);
delay(80);
}
delay(300);
for (int n = 0; n < 3; n++) {
allOn();
delay(150);
allOff();
delay(150);
}
delay(800);
}loop() plays the show in order: fill up, hold, empty out, flash three times, then rest.
const int FIRST_PIN = 2;
const int NUM_LEDS = 10;
void allOff() {
for (int i = 0; i < NUM_LEDS; i++) {
digitalWrite(FIRST_PIN + i, LOW);
}
}
void allOn() {
for (int i = 0; i < NUM_LEDS; i++) {
digitalWrite(FIRST_PIN + i, HIGH);
}
}
void setup() {
for (int i = 0; i < NUM_LEDS; i++) {
pinMode(FIRST_PIN + i, OUTPUT);
}
}
void loop() {
for (int i = 0; i < NUM_LEDS; i++) {
digitalWrite(FIRST_PIN + i, HIGH);
delay(80);
}
delay(500);
for (int i = NUM_LEDS - 1; i >= 0; i--) {
digitalWrite(FIRST_PIN + i, LOW);
delay(80);
}
delay(300);
for (int n = 0; n < 3; n++) {
allOn();
delay(150);
allOff();
delay(150);
}
delay(800);
}
Q1. Which part runs again and again?
Q2. What makes this a light show?
Speed up the wave — change delay(80) to delay(40) in both wave parts.
Hint: These are the delay lines inside the loops that light the lights one by one.
Add one more flash — change the flash count from n < 3 to n < 4.
Hint: Find for (int n = 0; n < 3; n++).
A line-by-line tour of the sketch — the same steps as in Robot Gurukul Studio.
Program overview
Big idea
Every Arduino program has a top part, a setup() part that runs once, and a loop() part that runs again and again.
In this project
A row of ten lights fills up, empties out, and flashes — a real light show!
Tip
Read from the top to the bottom. Tap any word or line if you need help!
const int FIRST_PIN = 2;
const int NUM_LEDS = 10;
void allOff() {
for (int i = 0; i < NUM_LEDS; i++) {
digitalWrite(FIRST_PIN + i, LOW);
}
}
void allOn() {
for (int i = 0; i < NUM_LEDS; i++) {
digitalWrite(FIRST_PIN + i, HIGH);
}
}setup()
Big idea
setup() runs one time when the board turns on.
In this project
It gets all ten light pins (starting at pin 2) ready.
Why here
Things we do only once go inside setup().
void setup() {
for (int i = 0; i < NUM_LEDS; i++) {
pinMode(FIRST_PIN + i, OUTPUT);
}
}loop()
Big idea
loop() runs again and again, forever.
In this project
This is where the whole light show plays from start to finish.
Why here
Things that repeat go inside loop().
void loop() {
for (int i = 0; i < NUM_LEDS; i++) {
digitalWrite(FIRST_PIN + i, HIGH);
delay(80);
}
delay(500);
for (int i = NUM_LEDS - 1; i >= 0; i--) {
digitalWrite(FIRST_PIN + i, LOW);
delay(80);
}
delay(300);
for (int n = 0; n < 3; n++) {
allOn();
delay(150);
allOff();
delay(150);
}
delay(800);
}
Try this: Change a delay number inside loop(), then press Run to make the show faster or slower.
pinMode
Big idea
pinMode tells a pin if it will listen or push power out.
In this project
It makes each light pin ready to push power to a light.
Why here
It goes in setup() because we only set it once.
pinMode(FIRST_PIN + i, OUTPUT);
digitalWrite
Big idea
digitalWrite turns a pin ON or OFF.
In this project
ON lights up a light, OFF turns it dark. Here it turns one light off.
Why here
It goes in loop() so the lights can keep changing.
digitalWrite(FIRST_PIN + i, LOW);
delay
Big idea
delay means wait. Nothing else happens while it waits.
In this project
It sets how fast each part of the show plays.
Why here
Right after a light turns on or off.
delay(80);