Type2Color is a Python application that interfaces with an LED strip and allows you to change the color of a randomly selected LED by pressing keys on an input device (keyboard, buttons, etc.). The project also includes files to set up a systemd service to run the application at startup.
Before running the Type2Color application, make sure you have the following components installed:
- Python 3
- rpi_ws281x library for controlling the LED strip
- evdev library for interacting with input devices
- A compatible LED strip (number of LEDs and pin configuration as specified in the
type2color.pyfile) - Target platform: Raspberry Pi
- evtest tool to monitor the input device event
- Install the required Python libraries:
pip install rpi_ws281x evdev- Install the evtest to get the input id, if necessary:
dnf install evtestTo read the input event keys is necessary to configure the input device id. For that, use the evtest application:
sudo evtestAnd update it on code line:
dev = InputDevice('/dev/input/event[input id]')To run the Type2Color application, execute the type2color.py script with Python 3:
python3 type2color.pyThe application will start, and the LED strip will light up with a random color. Whenever a key is pressed on the input device, a randomly selected LED will change to a new color. The application will log the key pressed, the LED ID, and the RGB values of the new color.
To stop the application, press Ctrl + C.
The project includes a systemd service file type2color-startup.service, which allows you to run the application at system startup.
Follow these steps to set up the systemd service:
- Copy the
type2color-startup.servicefile to the systemd services directory:
sudo cp type2color-startup.service /etc/systemd/system/- Reload the systemd manager configuration:
sudo systemctl daemon-reload- Enable the
type2color-startup.serviceto run at startup:
sudo systemctl enable type2color-startup.service- Start the service:
sudo systemctl start type2color-startup.serviceNow, the Type2Color application will automatically start whenever your system boots up.
Feel free to modify the type2color.py script and systemd service file type2color-startup.service according to your specific requirements. You can change LED_COUNT, LED_PIN, LED_FREQ_HZ, LED_BRIGHTNESS, and other variables in the type2color.py script to adapt it to your LED strip configuration.
If you encounter any issues or errors, you can check the logs using the following command:
journalctl -u type2color-startup.serviceThis will display the logs related to the Type2Color systemd service and help you diagnose any problems.
Feel free to add additional details or instructions if necessary. Ensure that you provide accurate information about the installation steps and other prerequisites required to run the application successfully.