Script: led_blink_list
This script will blink the LEDs in sequence according to a list named pin_list.
- Enter the led_blink_list script (python.microbit.org/v/2 matches the screencaptures).
- Set the Script Name field to led_blink_list.
- Click Load/Save, and then click Download Project Hex to save your work.
- Make sure to close the Load/Save dialog box after downloading.
- In the python.microbit.org editor, click Connect, and then click Flash.
# led_blink_list
from microbit import *
pin_list = [pin13, pin14, pin15]
while True:
for pin in pin_list:
pin.write_digital(1)
sleep(500)
pin.write_digital(0)
Tests
- Verify that the lights repeat the same sequence over and over: green for 0.5 s, yellow for 0.5 s, and then red for 0.5 s.
- Try changing sleep(500) to sleep(100) and flash the modified script. Did you anticipate the effect of this change correctly?