LED sequences created using a Raspberry Pi Pico Using the Raspberry Pi Pico RP2040 microcontroller and Thonny software, create a number of LED sequences, each with four buttons to trigger one of the sequences.
Leonardo Flores González |
This project's hardware and software
Hardware components
- Raspberry Pi Pico
- LED (generic)
- Resistor 220 ohm
- Jumper wires (generic)
- USB Cable Assembly, USB Type A Plug to Micro USB Type B Plug
- 4 pin open pushbutton
Software apps and online services
- Raspberry Pi Thonny
import machine import utime led1 = machine.Pin(2, machine.Pin.OUT) led2 = machine.Pin(3, machine.Pin.OUT) led3 = machine.Pin(4, machine.Pin.OUT) led4 = machine.Pin(5, machine.Pin.OUT) led5 = machine.Pin(6, machine.Pin.OUT) led6 = machine.Pin(7, machine.Pin.OUT) led7 = machine.Pin(8, machine.Pin.OUT) led8 = machine.Pin(9, machine.Pin.OUT) led9 = machine.Pin(10, machine.Pin.OUT) led10= machine.Pin(11, machine.Pin.OUT) #Botones b1 = machine.Pin(16, machine.Pin.IN, machine.Pin.PULL_DOWN) b2 = machine.Pin(17, machine.Pin.IN, machine.Pin.PULL_DOWN) b3 = machine.Pin(18, machine.Pin.IN, machine.Pin.PULL_DOWN) b4 = machine.Pin(19, machine.Pin.IN, machine.Pin.PULL_DOWN) def led_sequence (a,b,c,d,e,f,g,h,i,j): led1.value(a) led2.value(b) led3.value(c) led4.value(d) led5.value(e) led6.value(f) led7.value(g) led8.value(h) led9.value(i) led10.value(j) while True: if b1.value() == 1: led_sequence(0,0,0,0,0,0,0,0,0,0) utime.sleep(0.03) led_sequence(1,0,0,0,0,0,0,0,0,0) utime.sleep(0.03) led_sequence(1,1,0,0,0,0,0,0,0,0) utime.sleep(0.03) led_sequence(0,1,1,0,0,0,0,0,0,0) utime.sleep(0.03) led_sequence(0,0,1,1,0,0,0,0,0,0) utime.sleep(0.03) led_sequence(0,0,0,1,1,0,0,0,0,0) utime.sleep(0.03) led_sequence(0,0,0,0,1,1,0,0,0,0) utime.sleep(0.03) led_sequence(0,0,0,0,0,1,1,0,0,0) utime.sleep(0.03) led_sequence(0,0,0,0,0,0,1,1,0,0) utime.sleep(0.03) led_sequence(0,0,0,0,0,0,0,1,1,0) utime.sleep(0.03) led_sequence(0,0,0,0,0,0,0,0,1,1) utime.sleep(0.03) led_sequence(0,0,0,0,0,0,0,0,0,1) utime.sleep(0.03) led_sequence(0,0,0,0,0,0,0,0,0,0) utime.sleep(0.5) led_sequence(0,0,0,0,0,0,0,0,0,1) utime.sleep(0.03) led_sequence(0,0,0,0,0,0,0,0,1,1) utime.sleep(0.03) led_sequence(0,0,0,0,0,0,0,1,1,0) utime.sleep(0.03) led_sequence(0,0,0,0,0,0,1,1,0,0) utime.sleep(0.03) led_sequence(0,0,0,0,0,1,1,0,0,0) utime.sleep(0.03) led_sequence(0,0,0,0,1,1,0,0,0,0) utime.sleep(0.03) led_sequence(0,0,0,1,1,0,0,0,0,0) utime.sleep(0.03) led_sequence(0,0,1,1,0,0,0,0,0,0) utime.sleep(0.03) led_sequence(0,1,1,0,0,0,0,0,0,0) utime.sleep(0.03) led_sequence(1,1,0,0,0,0,0,0,0,0) utime.sleep(0.03) led_sequence(1,0,0,0,0,0,0,0,0,0) utime.sleep(0.03) led_sequence(0,0,0,0,0,0,0,0,0,0) utime.sleep(0.5)
Download Full Code: Click Here
Author Credit: Leonardo Flores González
Posts You May like:
- The RP2040 Raspberry Pi Pico Meets LoRa
- Pico supports SD cards and FatFS
- How to connect a Raspberry Pi Pico to LoRaWAN
- 50 Raspberry Pi Hacks & Tips You Should Know
- How to Install Wi-Fi and Internet on a Raspberry Pi Pico
- Easiest Way to to Run DC Motor with Raspberry Pi Pico
- Drag-and-Drop Programming For The Raspberry Pi Pico
- Make Pico DIY Project Without Any Soldering or Breadboard
- Detailed Comparison of Arduino Nano RP2040 Connect Vs Raspberry Pi Pico
- Make a USB Microphone Using the Raspberry Pi Pico
- The RP2040 is Now Available for $1
- Pico LoRa Expansion is Finally Out! Supports 868MHz
- CircuitPython 6.3.0 is Now Available with Improvement & Fixes
- Pico DIY Projects! Must Try 17 Different Pico HATs & Expansions