Mission 02 · Stage 1

Fast & Slow Blink

changing delay() values

Alternate fast and slow blink speeds by changing delay() values.

Fast & Slow Blink circuit diagram

Pin connections

Part 1Part 2

Resistor

pin 1

Breadboard

6t b

Resistor

pin 2

Breadboard

10t b

LED

anode (+)

Breadboard

4t b

LED

cathode (-)

Breadboard

3t b

Arduino

pin 13

Breadboard

10t e

Breadboard

6t e

Breadboard

4t e

Breadboard

3t e

Arduino

GND

See it

Let's blink at two speeds!

One little light blinks fast like a heartbeat, then slow like a sleepy yawn.

Fast and slow blinks are everywhere — quick on a game controller, slow on a phone charging.

The story

The problem

One blink speed is a little boring. Let's learn how to make a light blink fast AND slow.

Think of it like

It's like clapping — fast-fast, then slow-slow. The clap is the same, only the waiting changes.

Meet the parts

Holds all the parts and joins them, like a LEGO baseplate.

Breadboard

Our building board

Loading part…

It thinks and tells the light when to blink fast or slow.

Arduino

The brain

Loading part…

Slows the power down so the light does not get hurt.

Resistor

The protector

Loading part…

A tiny light that glows when it gets power.

LED

The light

Loading part…

How it works

1

Blink fast — ON

The light turns on, then waits only a tiny bit (150) — a quick flash.

digitalWrite(LED_PIN, HIGH);
delay(FAST_MS);
2

Blink fast — OFF

The light turns off for the same short wait. That makes the second fast blink.

digitalWrite(LED_PIN, LOW);
delay(FAST_MS);
3

Blink slow — ON

Now the light stays on much longer (800). You can really see this slow blink.

digitalWrite(LED_PIN, HIGH);
delay(SLOW_MS);
4

Blink slow — OFF

After the long wait, loop() jumps back to the fast blinks and does it all again!

digitalWrite(LED_PIN, LOW);
delay(SLOW_MS);

Then loop back to step 1

Build the circuit

Follow these steps in order. Match the wires to the colors shown.

  1. 1

    Place Breadboard

    Place the Breadboard (bb1) on the breadboard.

    Breadboard placed — build like the real world!

    Loading part…
  2. 2

    Place Arduino

    Place the Arduino (uno) on the breadboard.

    Arduino placed — ready to build!

    Loading part…
  3. 3

    Place Resistor

    Place the Resistor (r1) on the breadboard.

    Resistor in — it keeps the light safe!

    Loading part…
  4. 4

    Place LED

    Place the LED (led1) on the breadboard.

    Light plugged in — let's make it blink!

    Loading part…
  5. 5

    Connect Arduino pin 13 to Breadboard (bb1) 10t.e

    Arduino pin 13 into the resistor's column 10 — use any free hole in that column

    Tip: Arduino pin 13 into the resistor's column 10 — use any free hole in that column

    Power can now reach the resistor!

  6. 6

    Connect Breadboard (bb1) 6t.e to Breadboard (bb1) 4t.e

    Jumper the resistor's column 6 to the LED's anode column 4 — any free hole in each column

    Tip: Jumper the resistor's column 6 to the LED's anode column 4 — any free hole in each column

    Resistor joined to the light!

  7. 7

    Connect Breadboard (bb1) 3t.e to Arduino GND

    LED cathode column 3 straight to Arduino GND — any free hole in column 3

    Tip: LED cathode column 3 straight to Arduino GND — any free hole in column 3

    Circuit complete!

Try it

  • Press the green Run button — watch two quick blinks, then two slow ones.
  • Say the rhythm out loud: fast-fast, slow-slow, again and again!

Peek at code

The two speed nicknames

const int LED_PIN = 13;
const int FAST_MS = 150;
const int SLOW_MS = 800;

FAST_MS is the short wait (150) and SLOW_MS is the long wait (800). Change these numbers to change the speeds.

setup() — runs once

void setup() {
  pinMode(LED_PIN, OUTPUT);
}

setup() runs one time when the board turns on. pinMode gets pin 13 ready to power the light.

loop() — fast then slow

void loop() {
  digitalWrite(LED_PIN, HIGH);
  delay(FAST_MS);
  digitalWrite(LED_PIN, LOW);
  delay(FAST_MS);
  digitalWrite(LED_PIN, HIGH);
  delay(SLOW_MS);
  digitalWrite(LED_PIN, LOW);
  delay(SLOW_MS);
}

loop() does two fast blinks, then two slow blinks. The delay numbers — not digitalWrite — pick the speed.

Show full sketch (fast-slow-blink.ino)
const int LED_PIN = 13;
const int FAST_MS = 150;
const int SLOW_MS = 800;
void setup() {
  pinMode(LED_PIN, OUTPUT);
}
void loop() {
  digitalWrite(LED_PIN, HIGH);
  delay(FAST_MS);
  digitalWrite(LED_PIN, LOW);
  delay(FAST_MS);
  digitalWrite(LED_PIN, HIGH);
  delay(SLOW_MS);
  digitalWrite(LED_PIN, LOW);
  delay(SLOW_MS);
}

Quick quiz

Q1. Which part runs again and again?

  • A. loop()
  • B. setup()
  • C. pinMode only
Why: Yes! loop() runs again and again, forever.

Q2. What does a bigger number inside delay() do?

  • A. Waits longer
  • B. Makes the light brighter
  • C. Runs setup() again
Why: Yes! A bigger number means a longer wait, so the blink is slower.

Code lab — try on your own

  1. Make the fast blinks even quicker by making FAST_MS smaller.

    Hint: Try 80 or 100 instead of 150 on the FAST_MS line.

  2. Make the slow blinks even longer by making SLOW_MS bigger.

    Hint: Try 1200 or 1500 instead of 800 on the SLOW_MS line.

Code walkthrough

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

The light blinks two quick blinks, then two slow blinks, forever.

Tip

Read from the top to the bottom. Tap any word or line if you need help!

const int LED_PIN = 13;
const int FAST_MS = 150;
const int SLOW_MS = 800;

setup()

Big idea

setup() runs one time when the board turns on.

In this project

It gets pin 13 ready for our light.

Why here

Things we do only once go inside setup().

void setup() {
  pinMode(LED_PIN, OUTPUT);
}

loop()

Big idea

loop() runs again and again, forever.

In this project

This is where the light blinks fast, then slow.

Why here

Things that repeat go inside loop().

void loop() {
  digitalWrite(LED_PIN, HIGH);
  delay(FAST_MS);
  digitalWrite(LED_PIN, LOW);
  delay(FAST_MS);
  digitalWrite(LED_PIN, HIGH);
  delay(SLOW_MS);
  digitalWrite(LED_PIN, LOW);
  delay(SLOW_MS);
}

Try this: Change a delay number inside loop(), then press Run to see the blink speed change.

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 changing.

  digitalWrite(LED_PIN, HIGH);

delay

Big idea

delay means wait. Nothing else happens while it waits.

In this project

A short wait makes fast blinks, a long wait makes slow blinks.

Why here

Right after we turn the light on or off.

  delay(FAST_MS);