Runs your sketch
Arduino
Brain
decrement a variable over time
Count down from 10 to 0 using an int variable and Serial output.

T-minus… Liftoff!
secondsLeft counts down from 10 — each second prints until blastoff.
Rocket launches, game timers, and oven timers all count down a variable to zero.
The problem
You need a number that shrinks over time until something exciting happens.
Think of it like
Like counting backwards before hide-and-seek — 10, 9, 8… then GO!
Runs your sketch
Arduino
Brain
Show current count
Every loop pass prints the value stored in secondsLeft.
Serial.print("T-minus ");
Serial.println(secondsLeft);Check for liftoff
When the variable hits zero, we celebrate and stop counting down.
if (secondsLeft <= 0) {
Serial.println("Liftoff!");
}Subtract one second
After waiting one real second, the variable drops by 1 — then loop() prints again.
secondsLeft = secondsLeft - 1; delay(1000);
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!
Countdown variable
int secondsLeft = 10;
secondsLeft starts at 10 — an int variable that will shrink each second.
Liftoff check
while (true) {
delay(1000);
}
}
secondsLeft = secondsLeft - 1;When secondsLeft reaches 0, print Liftoff! and stay in an endless wait.
Decrement each second
}
Subtract 1 from the variable, then delay(1000) for one real second.
int secondsLeft = 10;
void setup() {
Serial.begin(9600);
Serial.println("Countdown starting...");
}
void loop() {
Serial.print("T-minus ");
Serial.println(secondsLeft);
if (secondsLeft <= 0) {
Serial.println("Liftoff!");
while (true) {
delay(1000);
}
}
secondsLeft = secondsLeft - 1;
delay(1000);
}
Q1. What is a variable?
Q2. What happens when secondsLeft reaches 0?
Start from 15 — change int secondsLeft = 10 to int secondsLeft = 15.
Hint: Line 1 at the top.
Count down faster — change delay(1000) to delay(500) at the end of loop().
Hint: Line 18.
A line-by-line tour of the sketch — the same steps as in Robo Gurukul Studio.
Program overview
Technical
Sketches have globals, then setup() once, then loop() forever.
In this project
Count down from 10 to 0 using an int variable and Serial output.
Why here
Read from top to bottom. Hover words or lines for help!
int secondsLeft = 10;
setup()
Technical
Runs one time when the board turns on.
In this project
Sets up pins and libraries for Countdown Timer.
Why here
One-time setup belongs here—not in loop().
void setup() {
Serial.begin(9600);
Serial.println("Countdown starting...");
}loop()
Technical
Runs again and again after setup() is done.
In this project
This is the main action you see in Countdown Timer.
Why here
Repeating work (blink, read sensors) goes here.
void loop() {
Serial.print("T-minus ");
Serial.println(secondsLeft);
if (secondsLeft <= 0) {
Serial.println("Liftoff!");
while (true) {
delay(1000);
}
}
secondsLeft = secondsLeft - 1;
delay(1000);
}
Try this: Change numbers in loop(), then compile and run the simulator.
delay
Technical
Waits for some time. Nothing else runs during the wait.
In this project
Controls speed so you can see Countdown Timer in the simulator.
Why here
Right after an action that should stay the same for a moment.
delay(1000);
begin
Technical
Starts talking to the computer screen (serial monitor).
In this project
Lets Countdown Timer print debug messages.
Why here
Goes in setup() once before any Serial.print.
Serial.begin(9600);
Technical
Sends text to the serial monitor without a new line.
In this project
Shows values from Countdown Timer on the screen.
Why here
In loop() or setup() when you want to see what the board is doing.
Serial.print("T-minus ");println
Technical
Sends text to the serial monitor and starts a new line.
In this project
Prints one line of output for Countdown Timer.
Why here
In loop() when each reading should appear on its own line.
Serial.println("Countdown starting...");