'F' → Fullscreen
No new wiring: today uses Activity 2.4's three LEDs exactly as they are. Open 2-4-launch-countdown and save a copy as 2-5-mission-control. Work in the copy.
Every code block is your whole program, from line 1. The green + lines are what you add. Don't type the + sign.
Today, tasks also take lines out. Each one says which lines go and how long your program should be afterward.
all_off() and all_on(), after the three Pin lines.value() lines inside the loop with two calls, and the last three lines with one call. Your program goes from 27 lines to 31.from machine import Pinimport time
led1 = Pin(28, Pin.OUT)led2 = Pin(29, Pin.OUT)led3 = Pin(30, Pin.OUT)
def all_off(): led1.value(0) led2.value(0) led3.value(0)
def all_on(): led1.value(1) led2.value(1) led3.value(1)
led1.value(1)time.sleep(1)led2.value(1)time.sleep(1)led3.value(1)time.sleep(1)
for i in range(5): all_off() time.sleep(0.2) all_on() time.sleep(0.2)
all_off()light(led) after all_on().value(1), three sleep(1)) with three calls. 31 lines to 32.from machine import Pinimport time
led1 = Pin(28, Pin.OUT)led2 = Pin(29, Pin.OUT)led3 = Pin(30, Pin.OUT)
def all_off(): led1.value(0) led2.value(0) led3.value(0)
def all_on(): led1.value(1) led2.value(1) led3.value(1)
def light(led): led.value(1) time.sleep(1)
light(led1)light(led2)light(led3)
for i in range(5): all_off() time.sleep(0.2) all_on() time.sleep(0.2)
all_off()flash(times, pause). Its loop is the one from Task 1.all_off() after it with one call, flash(5, 0.2). Then add a slow systems check, flash(2, 0.5), before the countdown. 32 lines to 36.from machine import Pinimport time
led1 = Pin(28, Pin.OUT)led2 = Pin(29, Pin.OUT)led3 = Pin(30, Pin.OUT)
def all_off(): led1.value(0) led2.value(0) led3.value(0)
def all_on(): led1.value(1) led2.value(1) led3.value(1)
def light(led): led.value(1) time.sleep(1)
def flash(times, pause): for i in range(times): all_off() time.sleep(pause) all_on() time.sleep(pause) all_off()
flash(2, 0.5)
light(led1)light(led2)light(led3)
flash(5, 0.2)Four changes, one at a time. Record what happens, and undo each one before the next.
flash(5, 0.2). Run it. Is there an error? What do the LEDs end up doing?flash(2, 0.5) up so it sits above def all_off():. Run it, and copy the error message exactly.flash(2, 0.5) to flash(). Run it, and copy the error message exactly.led2.value(1) line inside all_on(). Run it. Which parts of the show changed, and which didn't?Two of these are errors and two aren't. For each, say why Python did or didn't complain.
Answer the following questions before submitting your work.
all_on() as your example.def light(led):, led is a parameter. Explain how it can be a different LED on each call.flash(5, 0.2) caused no error, but moving a call above its definition did. Explain the difference.Submit your 2-5-mission-control program file and your completed Activity 2.5 sheet.