As the festive vibes took over the office, our crew of elves (aka the employees) decided to spice up our workspace for the holidays. We love to decorate our office space every year for the holidays, but this year, we wanted to crank it up a notch. Armed with the awesome Arduino Opta PLC, we huddled together to sync up our Christmas lights with the catchiest carols we could find. Imagine the office twinkling and grooving to "Jingle Bells" and "Deck the Halls" β it's like a holiday party but with more LEDs! So, grab your Santa hat and a chair, let me spill the cocoa beans on how we turned our workspace into a tech-infused holiday hotspot.
The IdeaOur inspiration for this project came from the jaw-dropping videos of houses lit up like Christmas dreams, synchronized perfectly with joyous tunes. You know, those houses that make you hit replay on the video over and over again. We wanted to replicate some of that magic right here at the office. Many of these awe-inspiring setups use Vixen Lights, an open-source software that seems to be the secret sauce behind the magic. As we dove into the world of holiday light displays, we realized that we would need relays to bridge the connection between an Arduino (or any microcontroller) and the lights. And that's where the lightbulb moment hit us β literally! Enter our hero, the Opta PLC. Essentially an Arduino with the relays already built-in. Now we had everything we needed to start.
The PlanThis project is basically composed of four parts:
- Configuring Vixen Lights
- Creating the Arduino code to run on the microcontroller
- Making the electrical connections
- Decorating
Making the Display
Open the Vixen Lights software.
Click on 'Setup Display'
Add your microcontroller.
Open the drop-down menu on 'Controller' section to the right. Select 'Generic Serial' as the controller type. Click on the green plus button.
Choose a name for your controller.
Set the amount of outputs. This will depend on the amount of physical I/O that your microcontroller can handle. In our case, we chose 4, since the Opta has only 4 relay outputs.
Configure the controller
Click on the controller and then on the gear symbol to configure the controller.
Click on 'Setup/Change Serial Port'.
Select the correct COM port for your microcontroller and the desired Baud rate. It is important to note that you can choose any Baud rate you want as long as it matches the rate on your Arduino Sketch later. The rest of the parameters stay as they are.
Add the elements to your lights display
On the 'Elements' section to the right, on the drop-down menu select 'Generic Numbered Group' and click on the green plus button.
Choose a name for the group, a prefix for the group, and the number of items. The amount of items needs to match the number of outputs on your microcontroller.
Say no to setting up a dimming curve for the lights. Since we are only turning them on and off we don't need one.
Choose the single-color option, you can change the display color, but it is not necessary. That's it for the elements.
Patchingthe elements and the outputs
Select both the elements and the controller and click on the 'Patch Elements' button.
You will get a confirmation message.
You can click on the 'Graphical View' section to check that the elements were patched together correctly. If you see any configuration blocks in between the elements you can delete them manually by clicking on them and hitting the delete key. Afterwards, you'll need to patch the elements together again.
If you see something like the image above, the setup was successful, you can now click on the lower right corner on the 'OK' button to close this window.
Creating the Sequence
Open Vixen Lights again and click on the "New Sequence..." button.
Navigate to Tools > Audio > Asociate Audio...
A file explorer window will open, select your favorite Christmas song and click OK.
You will now be able to see the song in the software. You can now start adding the effects for the lights if you want. We are going to use another audio tool the software has to offer.
In Tools > Audio, you will now see the option to use "Beat/Bar detection". Click on that option.
In this window, you can set up the parameters for your song. After clicking on generat the software will automatically make marks on every beat so we can synchronize the song and lights more easily.
We are going to use only the basic Effect "Chase" for this project since our lights are basic LED on and OFF lights.
Now we can add the effects to the timeline to make a sequence.
For our application, we will modify the brightness curve so it is always at max.
Now we are set on the Vixen Lights side of the project. After making the connections and the Arduino sketch we can just hit play and watch the lights follow the sequence.
Creating the Arduino codeVixen Lights sends data to the microcontroller via USB serial. In the Arduino sketch, we need to take that input and send it to the correct output so we can control the desired lights. In our case, we need to take the serial commands and send them to each relay to close or open it accordingly.
Broken dreams
This is the part where we hit a major roadblock on our project. We wanted to use the Opta alone for this project, and in theory, it is completely possible and compatible. But when we tried to connect the Opta directly to Vixen lights, the software would either crash or never output anything to the controller. We debugged the problem extensively and realized there was an issue with connecting the Opta to the software, we would get an error in the output logs saying that it was impossible to open the serial port for the Opta. The people at Vixen are very nice and are currently helping us nail down what the issue is and fix it. You can follow the issue here, and who knows, maybe by the time you are reading this, it will already be fixed. In the meantime, to get the project working before Christmas, we have opted to use an Arduino UNO as a bridge to the Opta.
The Code
The sketch used on the Arduino side is rather simple. It is composed of the UNO sketch in the regular Arduino IDE and the Opta sketch made in the Arduino PLC IDE.
Arduino UNO
First, we define the channels that we are going to use on the microcontroller. We left the option to use the sketch with the Opta as a comment.
For the setup, we set the begin the serial communication and set all the channels as outputs and in LOW so they start turned off.
In the loop we check for the serial communication and then send the result to the corresponding channel to turn the lights on or off.
Arduino Opta
The PLC IDE is the Arduino solution to program PLC compatible Arduino devices using IEC 61131-3 standard languages. It can be downloaded from the Arduino software page.
The PLC IDE side of the project is just a direct input of the signals from the Arduino UNO directed to the relay outputs of the Opta. We just need to creat a new project for the Opta. I wont go into much detail on how to set up the board. It can be read on Arduino Docs.
We use a comparator to check on the PLC if the input is in HIGH and activate the relays.
We set up the programmable inputs.
And set up the relay outputs.
That is everything we need to load on the microcontrollers.
Making the electrical connectionsThe connections were relatively simple. The only hard part was making the connections to Christmas lights from the relays. We had to make some modified extension cords so the live wire should go through the Opta relays. One side connects to the wall outlet and the other to the lights, the cables in the middle go into the Opta.
Note: electricity is very dangerous, do not attempt to recreate the extension cords we made if you are not comfortable with it.
The complete system
The complete system would look something like this. A direct connection from the the UNO to the Opta. Then connecting the modified extension cords to the relays and then just connecting the Christmas lights to the extensios cords as usual.
We also need to connect the Arduino UNO to the laptop that will be running the software.
The only other thing that we need is external power for the Opta. If we want to use the relay outputs on the Opta we requiere a at least 12 V DC. For this we will be using one of our own boards, the CatSink. CatSink is an USB-C PD board based on the Cypress CYPD3177 USB PD Controller. It offers the option to negotiate power delivery from a compatible power supply. In this case we will use a simple PD phone charger capable of 12V.
After finishing all the preparations, we took some time here at the office to decorate together as a team. We decided to go for four sections on the Christmas tree, that would correspond to the four possible outputs on the Opta. And it ended up looking like this:
The Light ShowThe End
Ready to turn your space into a festive spectacle? Grab an Arduino, some twinkling lights, and let the holiday magic begin! Whether you're a tech enthusiast or just someone looking to add a dash of cheer, we hope to have inspired you to create a dazzling display. Wishing you all a tech-filled and joyous holiday season β may your lights shine bright and your days be merry and bright! Happy holidays, everyone! ππ
Comments