LED Sign is a Raspberry Pi Pico W project that
- reads the distance to an object (ultrasonic sensor) and
- changes the LED strip color based on that distance,
- and additionally exposes a small Web UI + REST API to control the LEDs.
- Raspberry Pi Pico W
- Individual addressable RGB LED strip (WS2812/NeoPixel compatible)
- Ultrasonic distance sensor (e.g. HC-SR04 compatible)
- Flash MicroPython onto the Pico W.
- Copy
settings.example.pyand rename it tosettings.py. - Important: Edit
settings.pyand set your Wi-Fi and pins. - Upload the files to the Pico W and reboot it. This can be done in two ways:
- Execute
py .\deploy.py -a -s -r -l. This will copy all necessary files (includingsettings.py), reboot the Pico W and start reading the serial output. - Copy the necessary files manually to the Pico W and reboot it.
- Execute
- The IP-address given to the Pico W will be printed on the serial console.
deploy.py is a helper script to copy the necessary files to the Pico W and optionally reboot and read logs.
It supports the following flags:
-hto show the help message-p portto specify the serial port (e.g.COM3, standard: auto-detect)-ato copy all necessary files-f filename filename2to copy the given files-d dirname dirname2to copy the given directories-sto copysettings.py-rto reboot the Pico W after deployment-lto start reading the serial output (logs) after deployment
You can change the colors of the LED strip through two different HMIs:
- Web UI at
http://<pico-ip>/ - Ultrasound sensor
The measured distance (cm) of the ultrasound sensor maps to different colors:
< 3blink + OFF3..6RED6..9ORANGE9..12YELLOW12..15GREEN15..18BLUE18..21PURPLE
After the Pico is connected to Wi-Fi, open:
http://<pico-ip>/
The UI offers:
- RGB color picker
- OFF button
- Effects: Breath, Cycle, Lottery, Candy Tornado
Note: Any change of color, which is made either through the Web UI or the ultrasound sensor, cancels the currently running LED animation task (effect).
- On boot (
boot.py) the Pico tries to connect to Wi-Fi and prints the assigned IP- If Wi-Fi is not available, it keeps retrying asynchronically
- The ultrasound sensor will still be available
- Also on boot, the homepage with the current version is generated:
lib/static/index.htmlcontains a{{VERSION}}placeholderboot.pyreplaces it with the version frompyproject.toml- output is written to
lib/generated/index_with_version.html
- In
main.pythe ultrasonic distance loop starts and updates the LEDs continuously based on the measured distance - The web server is started on port 80 (if a Wi-Fi connection is available)
For a smoother experience, reserve a static lease for the Pico in your router/DHCP settings (recommended) or implement a fixed IP configuration in MicroPython.
- Web UI shows 404 / blank page: ensure
boot.pyran and createdlib/generated/index_with_version.htmland thatlib/static/exists. - Cannot connect to Wi-Fi: re-check
SSID/Passwordinsettings.py. The device prints connection attempts and errors on the serial console. - Webserver not reachable: verify the printed IP and that your client is in the same network. Server runs on port 80.
- LEDs stay off: verify
NumLEDs,LEDPin, power supply and LED type. - Distance colors keep updating: the distance loop runs continuously. Verify that the ultrasound sensor points into a direction that has no object in its way (at least 25 cm).
- Feature request: contact one of the collaborators
- Bug report: open an issue or contact SirDaywalker