It counts the numbers and blinks the light.
Arduino
The brain
int variable stores a count
Use an int variable to count loop repeats and print the count on Serial.

Pin connections
| Part 1 | Part 2 | |
|---|---|---|
Arduino pin 13 | → | Resistor pin 2 |
Resistor pin 1 | → | LED anode (+) |
LED cathode (-) | → | Arduino GND |
Watch a number grow!
A little box called loopCount adds 1 every time — and the light blinks for each count!
Step counters, scoreboards, and video game points all count up just like this.
The problem
We want the Arduino to remember a number and keep adding to it, even as the loop runs over and over.
Think of it like
It's like a clicker at a door — every click adds one more to the total.
It counts the numbers and blinks the light.
Arduino
The brain
Add one more
Every time loop() runs, we add 1 to loopCount. The box remembers the new total.
loopCount = loopCount + 1;
Show it on the screen
The screen prints the count so you can watch it go up: 1, 2, 3…
Serial.print("Count: ");
Serial.println(loopCount);Blink the light
A quick blink celebrates each new count before we start over.
digitalWrite(LED_PIN, HIGH); delay(200); digitalWrite(LED_PIN, LOW);
Wait, then do it again
Pause so you can read the number, then loop() adds one more.
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 count!
The counting box
const int LED_PIN = 13; int loopCount = 0;
loopCount is a box that holds a whole number. It keeps its value and grows each loop.
Get ready (setup)
pinMode(LED_PIN, OUTPUT);
Serial.begin(9600);
Serial.println("LED Counter — watch the count grow!");
}
void loop() {setup() runs once: it gets pin 13 ready for the light and opens the message screen.
Count and blink (loop)
Serial.print("Count: ");
Serial.println(loopCount);
digitalWrite(LED_PIN, HIGH);
delay(200);
digitalWrite(LED_PIN, LOW);
delay(800);
}
loop() adds 1, shows the count, blinks the light, waits — then does it all again!
const int LED_PIN = 13;
int loopCount = 0;
void setup() {
pinMode(LED_PIN, OUTPUT);
Serial.begin(9600);
Serial.println("LED Counter — watch the count grow!");
}
void loop() {
loopCount = loopCount + 1;
Serial.print("Count: ");
Serial.println(loopCount);
digitalWrite(LED_PIN, HIGH);
delay(200);
digitalWrite(LED_PIN, LOW);
delay(800);
}
Q1. What is a variable?
Q2. What does loopCount = loopCount + 1 do?
Start counting from 5 — change int loopCount = 0 to int loopCount = 5.
Hint: Line 2 at the top.
Make it count faster — change delay(800) to delay(400) at the end of loop().
Hint: The last delay in loop(), line 15.
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
We keep a number in a box, add 1 each time, show it on the screen, and blink a light.
Tip
Read from the top to the bottom. Tap any word or line if you need help!
const int LED_PIN = 13; int loopCount = 0;
setup()
Big idea
setup() runs one time when the board turns on.
In this project
It gets pin 13 ready for the light and opens the message screen.
Why here
Things we do only once go inside setup().
void setup() {
pinMode(LED_PIN, OUTPUT);
Serial.begin(9600);
Serial.println("LED Counter — watch the count grow!");
}loop()
Big idea
loop() runs again and again, forever.
In this project
This is where the number grows, the screen shows it, and the light blinks.
Why here
Things that repeat go inside loop().
void loop() {
loopCount = loopCount + 1;
Serial.print("Count: ");
Serial.println(loopCount);
digitalWrite(LED_PIN, HIGH);
delay(200);
digitalWrite(LED_PIN, LOW);
delay(800);
}
Try this: Change a number inside loop(), then press Run to see what happens.
pinMode
Big idea
pinMode tells a pin if it will listen or push power out.
In this project
It makes pin 13 ready to push power to the light.
Why here
It goes in setup() because we only set it once.
pinMode(LED_PIN, OUTPUT);
digitalWrite
Big idea
digitalWrite turns a pin ON or OFF.
In this project
ON lights up the LED, OFF turns it dark.
Why here
It goes in loop() so the light can keep blinking.
digitalWrite(LED_PIN, HIGH);
delay
Big idea
delay means wait. Nothing else happens while it waits.
In this project
It keeps the light on, and pauses so you can read each number.
Why here
Right after we turn the light on or off.
delay(200);
begin
Big idea
Serial.begin opens a message screen so the board can talk to the computer.
In this project
It lets us send the count to the screen.
Why here
It goes in setup() once, before we print anything.
Serial.begin(9600);
Big idea
Serial.print writes words or a number on the screen and stays on the same line.
In this project
It writes "Count: " right before the number.
Why here
In loop() so we can see each new count.
Serial.print("Count: ");println
Big idea
Serial.println writes on the screen and then jumps to a new line.
In this project
It prints a friendly hello when the board turns on.
Why here
So each message gets its own line.
Serial.println("LED Counter — watch the count grow!");