Overview
In this guide, we will control multiple LEDs to generate the Colorful Flowing Lights using the Raspberry Pi Pico Board. For this, we will again use the PWM technique like in the previous post about PWM Usage in Raspberry Pi Pico.
The five different LEDs with colors like Red, Blue, Green, Yellow, and White are connected to the GPIO pin of Raspberry Pi Pico. Using the MicroPython programming we will create a Colorful Flowing Lights pattern.
Components Required
In this guide, I used Elecrow Raspberry Pi Pico Starter Kit to test different Modules. You can buy the kit and perform some other operations as well. From this kit, you can use the following components.
1. Raspberry Pi Pico – 1
2. Red LED – 1
3. Green LED – 1
4. Blue LED – 1
5. Yellow LED – 1
6. White LED – 1
7. Breadboard – 1
8. Jumper Wires – 10
Circuit Diagram & Hardware Setup
Here is a circuit diagram for Colorful Flowing Lights using Raspberry Pi Pico.
Connect the 5 different LED positive terminal to GP0, GP1, GP2, GP3, GP4 & GP5. Connect the LEDs negative terminal to GND.
You can use jumper wires to connect all the LEDs with Raspberry Pi Pico Board.
MicroPython Code/Program
Copy the following Code to the Thonny Editor and run the script.
|
1 2 3 4 5 6 7 8 9 10 11 |
from machine import Pin import utime leds = [Pin(i,Pin.OUT) for i in range(0,5)] if __name__ == '__main__': while True: for n in range(0,5): leds[n].value(1) utime.sleep_ms(50) for n in range(0,5): leds[n].value(0) utime.sleep_ms(50) |
After running the script there will be a continuous flow of lights.












