Raspberry Pi Pico and LEDs

by Ramatronics Laboratory in Circuits > LEDs

1652 Views, 3 Favorites, 0 Comments

Raspberry Pi Pico and LEDs

WhatsApp Image 2023-04-18 at 5.03.56 PM.jpeg
WhatsApp Image 2023-04-18 at 5.03.58 PM.jpeg
led array_page-0001.jpg

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

WhatsApp Image 2023-04-18 at 5.49.50 PM.jpeg

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)

https://quartzcomponents.com/products/100-ohm-1-4-watt-resistor-with-1-tolerance-pack-of-10?_pos=3&_sid=dbcad0330&_ss=r

Bread Board(Full size and Half size)

https://quartzcomponents.com/products/colored-breadboard-mb-102-830-point?_pos=2&_sid=8db30d648&_ss=r

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

https://www.amazon.in/Raspberry-Pi-Pico-Microcontroller-Board/dp/B08PC3BV33/ref=sr_1_1?crid=3VOJFFHVMD2CQ&keywords=Raspberry+pi+pico&qid=1681818728&sprefix=raspberry+pi+pico%2Caps%2C369&sr=8-1

LEDs(size = 3mm, color = yellow, quantity = 10)

https://www.amazon.in/PGSA2Z-PGSA2Z%C2%AE-DIP-Led-Yellow/dp/B08WKH583F/ref=sr_1_5?crid=1RT9E5N8QCQ3D&keywords=LED+yellow+3+mm&qid=1681818672&sprefix=led+yellow+3+mm%2Caps%2C336&sr=8-5

Resistors(value = 100 Ohm, Quantity = 10, Power = 1/4W)

https://www.amazon.in/DIYtronics-100E-Resistor-Tolerance-Electronic/dp/B0BH8T6H81/ref=sr_1_17?crid=2SL85AXX8X85N&keywords=100+ohm&qid=1681818766&sprefix=100+ohm%2Caps%2C293&sr=8-17

Bread Board(Full size and Half size)

https://www.amazon.in/OLatus-Ol-Breadboard-Gl-Points-Solderless-Circuit/dp/B06XZ54VTN/ref=sr_1_1_sspa?crid=ME34RUD5WLA2&keywords=Bread+board&qid=1681818820&sprefix=bread+boar%2Caps%2C281&sr=8-1-spons&sp_csd=d2lkZ2V0TmFtZT1zcF9hdGY&psc=1

https://www.amazon.in/Electronic-Spices-Solderless-Breadboard-Prototype/dp/B0BN7X7FFT/ref=sr_1_4?crid=ME34RUD5WLA2&keywords=Bread+board&qid=1681818820&sprefix=bread+boar%2Caps%2C281&sr=8-4

Jumper wires(Male-to-Male)

https://www.amazon.in/ESTALLION-Jumper-Female-breadboard-jumper/dp/B09PBFV355/ref=sr_1_1_sspa?crid=5ES44LW8ZQX6&keywords=jumper%2Bwires&qid=1681818897&sprefix=jumper%2Bwires%2Caps%2C316&sr=8-1-spons&sp_csd=d2lkZ2V0TmFtZT1zcF9hdGY&th=1

Micro-B USB Cable

https://www.amazon.in/Solero-MB301-Charging-480Mbps-1-5-Meter/dp/B08Y1SJVV5/ref=sr_1_12_sspa?crid=2NPR6O2D7M7VX&keywords=Micro%2BB%2BUSB&qid=1681818941&sprefix=micro%2Bb%2Busb%2Caps%2C344&sr=8-12-spons&sp_csd=d2lkZ2V0TmFtZT1zcF9tdGY&th=1

Making the Circuit on Bread Board

WhatsApp Image 2023-04-18 at 5.49.50 PM (2).jpeg
WhatsApp Image 2023-04-18 at 5.49.50 PM (1).jpeg
WhatsApp Image 2023-04-18 at 5.49.50 PM.jpeg
WhatsApp Image 2023-04-18 at 5.03.59 PM.jpeg
led array_page-0001.jpg

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)

     

       

     

     


     

         

       

     

     

       

     

    

Run the Micro Python Program

WhatsApp Image 2023-04-18 at 5.03.55 PM.jpeg
WhatsApp Image 2023-04-18 at 5.03.54 PM.jpeg
WhatsApp Image 2023-04-18 at 5.03.53 PM.jpeg
WhatsApp Image 2023-04-18 at 5.03.52 PM.jpeg