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

Arduino

pin 13

Resistor

pin 2

Resistor

pin 1

LED

anode (+)

LED

cathode (-)

Arduino

GND

See it

Same blink — two speeds!

Change delay() numbers to make the LED blink fast, then slow.

Different blink speeds mean different things on real devices.

The story

The problem

One blink speed is boring — you want to control timing.

Think of it like

Like clapping fast then slow — the action is the same, the pause changes.

Meet the parts

Runs your sketch

Arduino

Brain

Loading part…

Limits current to the LED

Resistor

Safety

Loading part…

Shows output from the code

LED

Light

Loading part…

How it works

1

Blink fast — ON

The LED turns on, then waits only 150 ms — a quick flash.

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

Blink fast — OFF

Same short pause with the LED off. FAST_MS controls both quick blinks.

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

Blink slow — ON

Now delay(SLOW_MS) keeps the LED on much longer — easy to see the difference.

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

Blink slow — OFF

After the long pause, loop() starts over with fast blinks 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 Arduino

    Place the Arduino (uno) on the breadboard.

    Arduino placed!

    Loading part…
  2. 2

    Place Resistor

    Place the Resistor (r1) on the breadboard.

    Loading part…
  3. 3

    Place LED

    Place the LED (led1) on the breadboard.

    Loading part…
  4. 4

    Connect Arduino pin 13 to Resistor (r1) 2

    Connect Arduino pin 13 to Resistor (r1) 2.

  5. 5

    Connect Resistor (r1) 1 to LED (led1) anode (+)

    Connect Resistor (r1) 1 to LED (led1) anode (+).

  6. 6

    Connect LED (led1) cathode (-) to Arduino GND

    Connect LED (led1) cathode (-) to Arduino GND.

Try it

  • Press Run — watch two quick blinks, then two slow ones.
  • Count the rhythm: fast-fast, slow-slow, repeat!

Peek at code

Timing constants

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

FAST_MS and SLOW_MS are names for two different delay() lengths. Change these numbers to retune the whole pattern.

Setup the pin

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

setup() runs once and sets pin 13 as an output so we can drive the LED.

Fast then slow 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);
}

loop() alternates two fast blinks, then two slow blinks. The delay() numbers — not digitalWrite — set 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. Where does repeating work belong?

  • A. loop()
  • B. setup()
  • C. pinMode only
Why: Correct—loop() runs again and again.

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

  • A. Waits longer
  • B. Makes the LED brighter
  • C. Runs setup() again
Why: Yes — more milliseconds means a longer wait.

Code lab — try on your own

  1. Make the fast blinks even quicker by lowering FAST_MS (try 80 or 100).

    Hint: Edit the number on the line with FAST_MS = 150.

  2. Make the slow blinks longer by raising SLOW_MS (try 1200 or 1500).

    Hint: Edit the line with SLOW_MS = 800.

Code walkthrough

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

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

Why here

Read from top to bottom. Hover words or lines for help!

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

setup()

Technical

Runs one time when the board turns on.

In this project

Sets up pins and libraries for Fast & Slow Blink.

Why here

One-time setup belongs here—not in loop().

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

loop()

Technical

Runs again and again after setup() is done.

In this project

This is the main action you see in Fast & Slow Blink.

Why here

Repeating work (blink, read sensors) goes here.

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 numbers in loop(), then compile and run the simulator.

pinMode

Technical

Tells a pin if it listens or drives something.

In this project

Gets the Fast & Slow Blink circuit ready in the simulator.

Why here

Goes in setup() because we only set pins once at the start.

  pinMode(LED_PIN, OUTPUT);

digitalWrite

Technical

Turns a pin ON or OFF.

In this project

Controls lights, motors, or buzzers in Fast & Slow Blink.

Why here

Goes in loop() so it can keep changing while the program runs.

  digitalWrite(LED_PIN, HIGH);

delay

Technical

Waits for some time. Nothing else runs during the wait.

In this project

Controls speed so you can see Fast & Slow Blink in the simulator.

Why here

Right after an action that should stay the same for a moment.

  delay(FAST_MS);