Video: https://www.youtube.com/watch?v=VN7Q4Q9-Hpg
(old version before sending binary data to Arduino: https://www.youtube.com/watch?v=ITaTlD44Gg0)
Current version reaches ~14 fps. Previous one reached ~5 fps.
Images to come...
Hardware needed:
- Any WS2812b LED strip (and its power supply)
- One Arduino (Nano works fine)
Installation steps:
- Plug the Arduino Nano to your computer (host PC) with USB.
- Plug the Arduino ground PIN to the negative PIN of the powersupply (or to the ground of the LED strip).
- Plug the Arduino data PIN (default is PIN D4) to the data PIN (middle one) of the WS2812b LED strip.
Project is made for Windows 10 with Python 3.9.7. (See this tutorial to get Python for Windows 10: https://docs.microsoft.com/en-us/windows/python/beginners)
Install the Python libs listed in requirements.txt file.
pip install -r requirements.txt
Run the .exe by double-clicking the ihm/LEDs Control Center.exe. Should work ¯\(ツ)/¯
If you want to re-build the .exe (useful only if you modified the ihm.py), run the following:
pyinstaller.exe --onefile --windowed --icon misc\\icon.ico --name 'LEDs Control Center' ihm.py
(maybe the full path for pyinstaller.exe will be needed) If you modify a Python script under the scripts folder, there is no need to re-build since the .exe calls these Python scripts avec Python.
Purple area is where you choose the RGB values for the unicolor mode.
Yellow area is where you can change COM port and baudrate. It should not be of great use once set in the config file.
Green area are the buttons to use to change the lightning mode:
-
Eteindre les lumières sets all LEDs to black (= off).
-
Suivi d'écran is the dynamic lightning which set LEDs to screen colors.
-
Couleur unie et fixe sets all LEDs to the color defined in the Purple area.
Red area is where you set and start the timer mode. First box is for minutes. Second box is for seconds. Then click the Minuteur button to start the timer.
Last text box (Info) displays some short - useless - info when clicking buttons.
2. Configure the config file
- Choose what monitor will be used for the dynamic lightning effect. ([ECRAN] Monitor)
- Set the width ([ECRAN] LargeurEcran) and the height ([ECRAN] HauteurEcran) of your screen in centimeters (edges NOT included).
- Measure the positions of your LEDs with respect to the screen for each side (top, bottom, left, right), in centimeters. Note that the total number of LEDs here should match the N_LEDS macro in the Arduino code.
- PositionLedsHaut is for top side LEDs, from left to right. Each number is a LED distance to top-left corner.
- PositionLedsBas is for bottom side LEDs, from left to right. Each number is a LED distance to bottom-left corner.
- PositionLedsGauche is for left side LEDs, from top to bottom. Each number is a LED distance to top-left corner.
- PositionLedsDroite is for right side LEDs, from top to bottom. Each number is a LED distance to top-right corner.
- Set the starting corner (where power and Arduino are plugged to the strip) ([LEDS] CoinDebutLeds)
- Set the strip direction (clockwise or counterclockwise), when you look at your screen and the LEDs are behind the screen. ([LEDS] SensParcoursLEDs)
- [LEDS] Luminosity should be left at 100% by default. This parameter is set within the app.
- [LIEN_SERIE] defines serial communication settings. It can be configured later within the app, except the SerialTimeout. Nevertheless, Baudrate is not expected to be changed. If the Arduino COM Port is always the same, you can set it there (COMPort).
- You could change the lib used to screenshot the screen in dynamic lightning mode. MSS is the faster. Other options will probably be removed. Leave MethodeScreenshot to mss.
- Finally you can change the pixels neighborhood used to compute each LED value in dynamic lightning mode.
- VoisinageHaut is the neighborhood for top LEDs. VoisinageBas is for bottom LEDs.
- [x,y] : x is the left/right neighborhood and y is the top/down one.
- For example: [100,500] for VoisinageHaut, will use a 200x500 pixel rectangle.
- VoisinageGauche is the neighborhood for left LEDs. VoisinageDroite is for right LEDs.
- [x,y] : x is the left/right neighborhood and y is the top/down one.
- For example: [100,500] for VoisinageGauche, will use a 100x1000 pixel rectangle.
- VoisinageHaut is the neighborhood for top LEDs. VoisinageBas is for bottom LEDs.
Open the Arduino code with Arduino IDE (https://www.arduino.cc/en/software). Download FastLED Arduino's library (go through this tuto and search for FastLED in the library manager: https://www.arduino.cc/en/guide/libraries)
Change the macros if needed (N_LEDS and PIN). N_LEDS is the number of LEDs you want to light up. It should match the LEDs you wrote in ihm/scripts/default_config.ini. PIN is the pinout of the Arduino, plugged into the LEDs strip control pin.
Compile and download the code to the Arduino. Arduino has to remain USB-plugged to the computer in order to receive messages from the control center.
FastLED (Arduino library) GitHub. Icon under GNU General Public License.