Week 6 · Session 2
Several values under one name, then a light of your own.
colors = ["red", "yellow", "green"]: square brackets, items separated by commas, kept in the order writtencolors[0] is "red", colors[1] is "yellow", colors[2] is "green". Positions start at 0len(colors) is 3, so the last position is len(colors) - 1colors[3] stops with IndexError: list index out of rangeRun it as it is, then follow the bullets.
colors[1] and colors[2]colors[3] and read the error. Which line does it point at?len(colors) now, and which position is the new one at?for Over a Listfor color in colors: hands the block "red", then "yellow", then "green"for holds the item itself, not its positionrange hands over counts. Use it when the count is the point, and the list when the item is"All off" once, after every color, without adding it to the listGP labels sit beside each pin. Physical positions count 1 to 40 around the board.
Pin(15, Pin.OUT) claims GP15 as an output: 3.3 volts for on, 0 volts for off. The number is the GP label, not the physical positionGP15 at position 20 and GND at position 38+, blue for -Do This Now
GND) to the blue - rail beside itGP15) to row 24, column a- railDo This Now
activities, New File, one_led.pyfrom machine import Pinled = Pin(15, Pin.OUT)led.on()- railGP15, lit by your own codeGP14 and GP13