'F' → Fullscreen
Today the board gets three LEDs, and by Activity 2.6 it will have five. Yesterday's layout took six columns and a jumper for one LED, so you will rebuild it smaller first. The GND wire to the top − rail stays.
Every code block is your whole program, from line 1. The green + lines are what you add for that task. Don't type the + sign.
Unplug the USB cable whenever you change the wiring.
With the USB cable unplugged, take yesterday's LED, resistor, jumper, and GPIO 28 wire off the board. Then build three LEDs, each in two neighboring columns:
| Part | Red LED (pin 28) | Yellow LED (pin 29) | Green LED (pin 30) |
|---|---|---|---|
| Wire from the RedBoard | GPIO 28 → a16 | GPIO 29 → a19 | GPIO 30 → a22 |
| LED (long leg first) | e16, e17 | e19, e20 | e22, e23 |
| Resistor | a17 → top − rail | a20 → top − rail | a23 → top − rail |
Each LED's whole loop is two columns, with no jumper. The wire feeds the first column, the LED carries the current into the second, and the resistor takes it from there straight up into the − rail, reaching over the + rail without touching it. The resistor comes after the LED this time. That is fine: in a single loop the same current flows through every part, so the resistor limits it from either side.
28, 29, and 30 sit side by side on the top header.
from machine import Pin
led1 = Pin(28, Pin.OUT)led2 = Pin(29, Pin.OUT)led3 = Pin(30, Pin.OUT)
led1.value(1)led2.value(1)led3.value(1)from machine import Pinimport 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)range(5) to range(10). Predict, then count. Put it back to 5.from machine import Pinimport 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)Three changes, one at a time. Record what happens, and undo each one before the next.
led1.value(0) right before led2.value(1), and led2.value(0) right before led3.value(1). What's lit at 2 s now?led2 use pin 30 and led3 use pin 29. Which color lights second?time.sleep(0.2), so it looks like this. Count the flashes.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)None of the three is an error. Each program runs to the end. For each one, say what the code actually told the board to do.
i counts 0, 1, 2, 3, 4 — use it to work out the sleep time.Answer the following questions before submitting your work.
for i in range(5):, the variable i is never used. Explain what the loop is controlling.time.sleep(0.2) out of the loop made the flashes disappear. Explain what the LEDs were actually doing during the loop.Submit your 2-4-launch-countdown program file and your completed Activity 2.4 sheet.