Controlling spotlights with Arduino

Hello, dear Habrchane! A friend bought spotlights, which are controlled with an infrared remote control, and asked to automate them so that every hour it would be possible to set the desired color and brightness. The idea is to set the settings for the aquarium so that the lighting switches automatically every hour for 24 hours.





For the implementation of the project, the Arduino UNO board was chosen, since there are ready-made libraries for reading and sending an infrared signal . First, the commands of the remote control were read using the VS1838B microcircuit (the Arduino library wrote that this is the LG protocol and 28 bits are used). I tried to generate the same signals using the sendLG function - nothing happened (there was no oscilloscope, there was no way to see the signal live). Therefore, 8 commands (enable, disable, brighter, darker, white, red, blue, pink) were read in raw mode, and each command had its own array of 67 unsigned int values. Of course, this is a bad decision, because it takes up 60% of the dynamic memory, but I had no other options how to solve this problem.





Then there was work on the menu of the device. It was necessary to give the opportunity to set the current time, as well as select the lighting parameters for each hour. A 20x4 character display was taken (I used a parallel connection, since the adapter to I2C was buggy) and three buttons, in total there were seven windows for the character display. To implement the menu, I had to tinker, using a Finite-state machine with 77 states.





Next, it was necessary to collect everything in the case. For this purpose, a smartphone box was chosen. I did not order the boards, because they are more expensive than the Chinese Arduino. Everything is assembled and connected with wires, as well as wrapped with electrical tape and glued with double-sided tape. A USB wire comes out of the case, it is used to power the device, as well as for programming (if there is a need to change something). Also from the body there are three wires for the infrared LEDs (to drive three floodlights), and one wire is the common ground.





So the mini-project is ready, I attach the code (in case someone wants to collect the same thing or improve it) and a video.








All Articles