First, insert the Raspberry Pi Pico into the breadboard. 
00:00
Next, connect the red, green, amber and blue LEDs as shown. First connect the red LED's anode (longer leg) to GP15. Make sure the 330 ohm resistor is connected to the anode of the LED.
00:00
Now connect the green LED to GP14, making sure that a 330 ohm resistor is also used here. 
00:00
Connect the amber LED to GP13.
00:00
Lastly, connect the blue LED to GP12, with a 330 ohm resistor connected to it anode.
00:00
Connect black jumper wires from the cathode of each LED (shorter leg), to a ground rail of the breadboard.
00:00
Finally, connect a black jumper wire from the ground rail of the breadboard to GND on the Pico.
00:00
As we've done so in previous lessons, we've imported the machine module so you can control the GPIO pins. Here, we've also imported the utime module to add delays for when the lights go on or off. Set each LED as an output; Make sure that the second parameter is machine.Pin.OUT
00:00
As we want the light show to repeat again and again, we used a while loop. The while loop in Micropython is used to iterate over a block of code in the loop body, while the expression evaluates to a True. In the code, while True , True here always evaluates to the boolean value, True, so the code here is executed indefinitely. 
00:00
Add the following code so that the LEDs turn on, one after another. There is a delay of 2 seconds in between each LED lighting up.
00:00
At the moment, all LEDs stay on after they are turned on. To turn them off, simply change their value to 0. For example, redLED.value(0).
00:00
Upload the code to the Pico with Ampy. The red LED should light up first. After two seconds, the green LED lights up. Again, there is a two second delay before it is followed by amber. There is another two second delay before blue LED lights up. The final bit of code completes the same pattern but this time in opposite, with the blue LED turning off first. 
00:00
main.py
xxx
Terminal
screen /dev/tty.usbmodem0000000000001 115200
>>> led = Pin(25, Pin.OUT)
>>> from machine import Pin
Breadboard
Breadboard
Mark
© 2022 Chick Commerce Pty Ltd