Raspberry Pi Pico and LEDs
by Ramatronics Laboratory in Circuits > LEDs
1652 Views, 3 Favorites, 0 Comments
Raspberry Pi Pico and LEDs
INTRODUCTION:
In this instructables, I am going to make an interesting project with LEDs. I have connected 10 3mm yellow LEDs to GPIO0 to GPIO9 pin of the raspberry pi pico. Now I start wiring different micro python programs to show different animations or patterns of the LEDs. After spending 1:30 hours on coding, I developed 9 different animations that have been given Step-2. Similarly you can also create your own animations to make a show of LEDs. So let's get started.
Supplies
List of Electronic Hardware:
https://quartzcomponents.com?sca_ref=3671286.DzEptz4I3w
Raspberry Pi Pico
https://quartzcomponents.com/products/raspberry-pi-pico?_pos=2&_sid=188f474e7&_ss=r
LEDs(size = 3mm, color = yellow, quantity = 10)
https://quartzcomponents.com/products/yellow-5mm-led?_pos=6&_sid=50ec88f82&_ss=r
Resistors(value = 100 Ohm, Quantity = 10, Power = 1/4W)
Bread Board(Full size and Half size)
Jumper wires(Male-to-Male)
https://quartzcomponents.com/products/65pcs-breadboard-jumper-cable?_pos=8&_sid=8d1a72324&_ss=r
Micro-B USB Cable
https://quartzcomponents.com/products/raspberry-pi-cable-for-charging?_pos=1&_sid=37ffa685f&_ss=r
Raspberry Pi Pico
LEDs(size = 3mm, color = yellow, quantity = 10)
Resistors(value = 100 Ohm, Quantity = 10, Power = 1/4W)
Bread Board(Full size and Half size)
Jumper wires(Male-to-Male)
Micro-B USB Cable
Making the Circuit on Bread Board
To make the circuit on the bread board, I am using two bread boards. A full size bread board and a half size. First I fix the raspberry pi pico on the bread board having half size. I make an another circuit on full size bread board on which I inserted 10 3mm yellow color LEDs in a row as shown in the given images. I have also added a 100 Ohm resistor between each cathode pin of led and negative supply rail of the bread board to limit the current.
I have connected each anode of the led to the raspberry pi pico according to given wiring scheme.
LED1---------->GPIO0
LED2---------->GPIO1
LED3---------->GPIO2
LED4---------->GPIO3
LED5---------->GPIO4
LED6---------->GPIO5
LED7---------->GPIO6
LED8---------->GPIO7
LED9---------->GPIO8
LED10---------->GPIO9
Writing the Micro Python Program
Open a new script in Thonny and write the following program. After writing the program save this file on the raspberry pi pico with name as main.py.
from machine import Pin
import utime
leds = [Pin(i, Pin.OUT) for i in range(0,10)]
if __name__ == '__main__':
while True:
#Animation-1
for n in range(0,10):
leds[n].value(1)
utime.sleep_ms(50)
for n in range(0,10):
leds[n].value(0)
utime.sleep_ms(50)
for n in range(9,-1,-1):
leds[n].value(1)
utime.sleep_ms(50)
for n in range(9,-1,-1):
leds[n].value(0)
utime.sleep_ms(50)
#Animation-2
for n in range(0,10):
leds[n].value(1)
utime.sleep(0.1)
leds[n].value(0)
for n in range(9,-1,-1):
leds[n].value(1)
utime.sleep(0.1)
leds[n].value(0)
#Animation-3
for n in range(0,10):
leds[n].value(0)
utime.sleep(0.1)
leds[n].value(1)
for n in range(9,-1,-1):
leds[n].value(0)
utime.sleep(0.1 )
leds[n].value(1)
#Animation-4
for n in range(0,10):
leds[n].value(1)
utime.sleep(0.1)
for n in range(9,-1,-1):
leds[n].value(0)
utime.sleep(0.1)
for n in range(9,-1,-1):
leds[n].value(1)
utime.sleep(0.1)
for n in range(0,10):
leds[n].value(0)
utime.sleep(0.1)
#Animation-5
for n in range(0,5):
leds[n].value(1)
leds[9-n].value(1)
utime.sleep(0.1)
leds[n].value(0)
leds[9-n].value(0)
#Animation-6
for n in range(0,5):
leds[n].value(0)
leds[9-n].value(0)
utime.sleep(0.1)
leds[n].value(1)
leds[9-n].value(1)
#Animation-6
for n in range(0,5):
leds[4-n].value(1)
leds[n+5].value(1)
utime.sleep(0.1)
leds[4-n].value(0)
leds[n+5].value(0)
#Animation-7
for n in range(0,5):
leds[4-n].value(0)
leds[n+5].value(0)
utime.sleep(0.1)
leds[4-n].value(1)
leds[n+5].value(1)
#Animation-8
for n in range(0,5 ):
leds[n].value(1)
leds[9-n].value(1)
utime.sleep(0.1)
leds[n].value(0)
leds[9-n].value(0)
for n in range(0, 5):
leds[4-n].value(1)
leds[n+5].value(1)
utime.sleep(0.1)
leds[4-n].value(0)
leds[n+5].value(0)