Back

Activity 2.4: Rocket Launch Countdown

divider

Activity 2.4

Rocket Launch Countdown

Key Concepts

Cumulative Sequencing

for Loops for Repetition

Today's Project: Mission Control

Three LEDs. T-minus 3, T-minus 2, T-minus 1 — then liftoff.

Not a Stoplight

A stoplight cycles — one light on at a time, forever. A countdown builds up — each light joins the ones before it, staying lit, all the way to a climax.

Same LEDs a stoplight could use. Completely different behavior.

Repeating, Not Traversing

Every for loop you've written so far processed something — a range of numbers, a list. Sometimes a for loop just repeats an action a fixed number of times, and the loop variable is never used.

for i in range(3):
print("Beep")

Repeating, Not Traversing

Terminal window
Beep
Beep
Beep

i is never printed — only its count matters.

Today's Objectives

  • Wiring three LEDs, each to their own GPIO pin
  • Building a cumulative sequence with Pin() objects
  • Using a for loop purely to repeat an action

Key Terms

Cumulative Sequence
A sequence where each new step joins the ones before it, instead of replacing them.

'F' → Fullscreen

divider

Build

Create a new MicroPython program named 2-4-launch-countdown.


Task 1: The Countdown

  • Wire three LEDs (with resistors) to GPIO 28, 29, and 30.
  • Turn them on one at a time, in sequence — without turning any of the previous ones off.

All three sit next to each other in the block of eight pins on the top header, but the board prints them right to left — reading along that block you will find 30, then 29, then 28:

The SparkFun IoT RedBoard RP2350 with the three pins labeled 30, 29, and 28 outlined together on the top header

The circuit diagram below is a schematic, not a picture of the board, so its pins are drawn in the order that makes the wiring clearest rather than the order they appear above.

Circuit diagram showing three LEDs, each with its own resistor, wired to GPIO 28, 29, and 30, sharing a common GND
[PHOTO PLACEHOLDER — Task 1: Three LEDs Wired, Countdown Lit]
Rocket Launch Countdown
from machine import Pin
import time
led1 = Pin(28, Pin.OUT)
led2 = Pin(29, Pin.OUT)
led3 = Pin(30, Pin.OUT)
led1.value(1)
time.sleep(1)
led2.value(1)
time.sleep(1)
led3.value(1)
time.sleep(1)

Task 2: Liftoff

  • Once all three LEDs are lit, blink all three together rapidly 5 times, then turn everything off.
Rocket Launch Countdown
from machine import Pin
import time
led1 = Pin(28, Pin.OUT)
led2 = Pin(29, Pin.OUT)
led3 = Pin(30, Pin.OUT)
led1.value(1)
time.sleep(1)
led2.value(1)
time.sleep(1)
led3.value(1)
time.sleep(1)
for i in range(5):
led1.value(0)
led2.value(0)
led3.value(0)
time.sleep(0.2)
led1.value(1)
led2.value(1)
led3.value(1)
time.sleep(0.2)
led1.value(0)
led2.value(0)
led3.value(0)

Challenge (Optional): Accelerating Liftoff

  • Make each countdown pause shorter than the last, so the countdown visibly speeds up toward liftoff.
  • Wrap the entire sequence in while True: so it repeats continuously as a standing demo.
divider

Checkpoint

When you run your script:

  • All three LEDs should light up in sequence, each staying lit as the next one joins
  • Once all three are lit, they should flash together rapidly several times
  • Everything should turn off at the end
divider

Reflection

Answer the following questions before submitting your work.

  1. Why does this project's build-up behavior avoid feeling like a stoplight, even if you used the same colors a stoplight might use?
  2. In for i in range(5):, what is the loop actually controlling, since i itself is never used or printed?
  3. How does this circuit reuse the Pin() object pattern from Activity 2.3, just applied to three pins instead of one?
divider

Submit

Submit the required files to the appropriate dropbox.

Activity Complete