This project is a Flask-based server designed to control LED displays using WS281x LED strips. It provides a REST API to receive LED colour values and a timer (etime
) to manage the display. The server runs on a Raspberry Pi and controls the LEDs by updating their colours based on the received hex colour values.
- Dynamic LED Display Control: Update LED colours in real-time through a REST API.
- Time-based LED Display Reset: Automatically turns off the LED display at a specified time.
- Flexible colour Configuration: Allows dynamic updates of LED colours via hex colour values.
- Flask
- rpi_ws281x
- pytz
Ensure you have Python 3 installed on your Raspberry Pi. This project uses the rpi_ws281x library for controlling WS281x LED strips and Flask for setting up the server.
-
Clone this repository to your Raspberry Pi.
-
Install the required libraries:
pip install flask rpi_ws281x pytz
-
Setup your LED strip by connecting it to the Raspberry Pi GPIO pin 18.
Before running the server, you may want to adjust the following variables in the code to match your LED strip setup:
NUM_ROWS
: Number of LED rows.LEDS_PER_ROW
: LEDs per row.LED_PIN
: The GPIO pin connected to the LED strip.LED_BRIGHTNESS
: Brightness level (0-255).
To start the server, run:
python path/to/your/script.py
This will start the Flask server on port 3000, allowing it to receive POST requests with LED colour values and etime.
-
POST /data: Updates the hex colour values for the LEDs and the
etime
(optional) when the display should reset. Expect a JSON payload withmessage
(array of hex colour values) andetime
(string, optional). -
GET /ping: Health check endpoint to verify the server is running.
Example POST request to /data
:
{
"message": ["#FF0000", "#00FF00", "#0000FF"],
"etime": "22:30"
}
Feel free to fork this project and submit pull requests with new features or improvements.