Raspberry Pi Pico W LED Controller is a simple example of how to manage a WS2812B LED strip using state buttons and a web interface. The project is based on the Raspberry Pi Pico SDK. The web interface is served by the Raspberry Pi Pico W itself.
- WS2812B LED strip controller
- IRQ based light state buttons handling
- Wi-Fi connection
- Web interface light state control
- NTP time synchronization
- Rainbow Wheel
- Rainbow Cycle
- Static Color
- Breathing
- Flashing
- Wave
- Fade
- Red
- Green
- Blue
- Cyan
- Yellow
- Pink
- Magenta
- Purple
- Orange
- Turquoise
- White
- Raspberry Pi Pico W
- WS2812B LED strip
- 5V power supply/supplies
For 120 LEDs to power, you will need a 5V power supply with at least 6A current. The power supply should be connected to the LED strip and the Raspberry Pi Pico W. For this project, two 5V 3A power supplies were used. General schema is shown below:
The code is written in C and follows src, include
structure. The project is based on the Raspberry Pi Pico SDK and FreeRTOS.
This project connect pico-sdk
and pico-extras
as submodules into the lib
directory.
For the project to build, you will need the following packages:
sudo apt-get update
sudo apt-get install -y cmake gcc-arm-none-eabi libnewlib-arm-none-eabi build-essential
There is gitignored Wi-Fi credentials file to create in following directory led_controller/include/wifi_credentials.h
:
#ifndef _WIFI_CREDENTIALS_H
#define _WIFI_CREDENTIALS_H
#define WIFI_SSID "wifi_ssid"
#define WIFI_PASSWORD "wifi_password"
#endif
Initialize the submodules:
cd lib/pico-sdk
git submodule update --init
To build the project, run:
mkdir build
cd build
cmake ..
make
Built LedController.uf2
file can be found in the build/led_controller
directory.
Before flashing the Raspberry Pi Pico W, connect the LED strip to the GPIO pin set in led_controller/include/led_controller.h
and power it according to instructions in previous paragraphs. The LED strip should light up with the default mode Rainbow Wheel
.
The web interface is a simple page that allows you to control the LED strip. It is served by the Raspberry Pi Pico W itself. Data fetch intervals are set to 5 seconds to avoid overloading the Pico W. Start timestamp is created by the server although counting elapsed is fully client-sided.
Note
Building the frontend separately with Python is an older practice. This could be avoided using CMAKE.
To build the web interface, simply run:
python3 makefsdata.py
If you will be using the web interface locally, you don't need https to install the app. In Chrome, resolve chrome://flags/#unsafely-treat-insecure-origin-as-secure
and your's Pico W IP address. Restart the browser and manifest.json will allow for the install. Then, Chrome flag can be set back to default.
After building the project, you can flash the Raspberry Pi Pico W with the generated led_controller.uf2
file obtained from build/led_controller/src
directory. The LED strip should light up with the default mode Rainbow Wheel
. You can change the color by choosing one of the buttons on the web interface. When connecting to the Wi-Fi for the first time, check the serial output for the IP address.
This project is licensed under the MIT License - see the LICENSE file for details.