Banner

Wednesday, March 21, 2012

DIY light show controller with Vixen and Arduino

Back in 2005, I saw Christmas light show and was instantly obsessed. It was well beyond my comprehension at the time but I vowed to one day do something like it.

Fast forward six years to Christmas 2011 and I finally met that goal. Because light-o-rama setups are quite expensive and I wanted a real challenge, I decided to try to build the entire setup from scratch.

I went into this knowing I wanted to use Vixen, as it seemed to be the best free option for light show controlling. The next step was to find a controller to work with it. Being a big Arduino fan, it seemed only logical to start there. I found some scraps of code on doityourselfchristmas.com, and I was off to a good start.


My final setup was Vixen outputting from my MacBook Pro (bootcamped) to the Arduino via Vixen's "generic serial driver". My code in the Arduino broke the serial stream into pins, which then ran to the relay board. The 5VDC from the Arduino would trigger a transistor (and LED), which would then trigger a 12VDC relay on the relay board. This completed the circuit on a homemade 110VAC power strip causing each light to light up. The result...


I was pretty proud, I have a couple other songs on my youtube channel. Still, it has quite a bit of evolving to do. I am making some revisions for next year that I wish I thought of in the initial design. Mainly, make several, smaller relay boards to place at strategic spots and run the signal lines. This is much cheaper and safer than my ridiculous method of a central control with 110VAC lines running all over the place.
 
Another thing to think about is multiplexing the signal line rather than breaking into pins at a central controller. If each relay satellite had a small micro-controller and a method of addressing, you could just spam the serial stream to each and have them decide what to take and what to ignore.

Most importantly, I desperately need PWM to get the lights to fade. I encourage anybody thinking about this project keeping this all in mind as it would have saved me a lot of money in the long-run. How much you ask?

My cost breakdown was roughly as follows:
Vixen Software - Free
Arduino Mega - $60
Relay Board Materials - $100
Outlet Power Strip Materials - $20
Lights - $150
Extension Cords - $200

Yup, the most expensive item were the extension cords. A reel of CAT5 could have replaced 90% of that if I would have thought to run signal wires in length instead of power. Wal-Mart did allow me to get 1500 feet of extension cords in 15' stretches for that price though. And I needed it.



Please don't call the fire dept on me...

If you're looking to do something like this, here is my Arduino code:
int C1 = 2;
int C2 = 3;
int C3 = 4;
int C4 = 5;
int C5 = 6;
int C6 = 7;
int C7 = 8;
int C8 = 9;
int i = 0;
int incomingByte[8];

void setup()
{
  Serial.begin(9600);
  pinMode(C1, OUTPUT);
  pinMode(C2, OUTPUT);
  pinMode(C3, OUTPUT);
  pinMode(C4, OUTPUT);
  pinMode(C5, OUTPUT);
  pinMode(C6, OUTPUT);
  pinMode(C7, OUTPUT);
  pinMode(C8, OUTPUT);
}

void loop()
{
  if (Serial.available() >= 8) {
    for (int i=0; i<=8; i++)
    {
      incomingByte[i] = Serial.read();
    }
    analogWrite(C1, incomingByte[0]);
    analogWrite(C2, incomingByte[1]);
    analogWrite(C3, incomingByte[2]);
    analogWrite(C4, incomingByte[3]);
    analogWrite(C5, incomingByte[4]);
    analogWrite(C6, incomingByte[5]);
    analogWrite(C7, incomingByte[6]);
    analogWrite(C8, incomingByte[7]);
  }
}

As a bonus, here is a poorly cut video showing different views of the setup:

Special thanks to:
Ashley - Motivation and wire debuncher
Josh - Relay board design and assembly
Peter - Uber debugger
Tyler - Light man (no fear of heights)
John - Fix lights that fell off man
Couldn't have happened without all of you.

15 comments:

  1. Do you have a part list? I'm looking at doing my own show hopefully this year and would like to know what you used for your relay board. I will be using an arduino uno instead of a Mega but the code should be similar. Any suggestions/help would be much appreciated.

    ReplyDelete
  2. Hi Nicholas,

    Here is the parts list for the control board:
    (all mouser p/n)
    571-17969490 : Terminal Blocks
    589-8100-410-LF : Breadboard
    273-1K-RC : 1K Resistors
    273-470-RC : 470ohm Resistors
    653-G5LE-1-DC12 : 12V Relays
    512-PN2222ABU : NPN Transistors
    Optional : LEDs

    An Uno should work great. My code above is for 8 pins on any Arduino. Just add pin variables to add channels.

    If you are keeping this under 8 channels, I recommend grabbing a Parallel Port Relay Board. They have a header on the board you can plug right into from the Arduino. This can be a cheaper (and safer) alternative when getting started.
    I actually prototyped with one of these before I made my big board. Now I use it as a dedicated Christmas tree controller.

    I'm remaking my entire setup for next year. The number of extension cords required in this setup was absurd. I really recommend making many smaller boards with cat5 running between the Arduino and the boards.
    Also keep in mind these mechanical relays can't do PWM (dimming). I believe the Uno has 6 PWM outputs. So I would consider grabbing a few solid state relays so you can dim some of the channels.

    If you have any other questions just let me know!

    ReplyDelete
    Replies
    1. Awesome thanks for the info, i will definitely look at the parallel relay board, and you are correct the uno does have 6 PWM outputs. I hate to bother you for more info but do you by chance have a wiring diagram for the relay board? If not that's ok I'm sure I can figure it out or find something online. I'm pretty stoked about this project and hope it's not too much for me. I just ordered a new soldering iron and can't wait to fire it up. thank you again for all your suggestions and assistance. I hope to be posting good results on my own website and if you want I will try to keep you posted on my progress.

      Delete
  3. Hi. I really like your set-up. I am trying to do the same but on a much smaller scale. I have a few questions though. I understand very little code and I can not work out how to link Vixen to my Arduino! Please could you help. I have an Arduino Uno and I am using Vixen 2 (I have tried 3 and dislike it). You help would be much appreciated. Many thanks.

    ReplyDelete
  4. Hi Edward, no problem. The code above works for 8 channels (it was what I used for the first prototype with a Parallel Port Relay Board), If you're starting at that size you can leave it as is, else you'll have to copy paste to add "int c", "pinMode", and "analogWrite" lines for each channel.

    But lets just get them talking with the code as-is first. Burn the code posted as a sketch to the Arduino Uno. Once that's done, move to the PC's side. Vixen has a lot of output drivers for the different controllers. In the list, they have one called the "generic serial driver" which is what we want. This lets Vixen output a simple serial stream over the Arduino's COM port (USB). The code grabs the serial data stream and converts it to pin toggles. Then you can use the 5V pins to drive your relay board.

    In the code above, the channel number from Vixen goes out to the next pin up. (This is because Arduino does serial stuff with pin 0 and pin 1.) So Channel 1 = pin 2, Channel 2 = pin 3, and so on.

    Hopefully that helps. If you have any other questions, feel free to ask!

    ReplyDelete
    Replies
    1. Thanks so much! This has helped me loads. This has sorted the connectivity issue between the Arduino and the PC, but whilst doing this, it has formed another problem. If I send a signal to pin 1 only, it will turn on an led (I am using LED's as my relay board has had enough! I have ordered a new one, but takes a while to come) but if I send the same signal to the same channel, it turns on a different led! Then, if I have channels 1 + 2 on, no lights turn on, but then if I run it again, different LED's turn on! I am really puzzled here! It doesn't really matter, I can still time the LED with the music as they turn on and off when I want, but it means I cant really make a show or do anything complex! It may just be me who is suffering this, and it would not surprise me it is is! It may also be my Arduino, in which case I may buy a new one, (I would probably go with the mega after seeing that it more advance.) I hope you can help me here!

      Many thanks!

      (P.S - Thanks for getting back to me so fast!)

      Delete
  5. Happy to help! The Arduinos are pretty hard to kill so I wouldn't order a new one just yet. To start debugging where I screwed up initially, are you sure you're hooked into the right pin? So a Vixen signal on pin 1 will actually turn pin 2 on the Arduino.

    Next, try changing the line of Arduino code "int C1 = 2;" to "int C1 = 13;" and reburn the sketch.
    This will make channel 1 toggle the pin 13 internal LED on the Arduino. It's just to rule out any funny LED issues.

    If it's still acting intermittent, I'd grab a serial port monitor program. I used one called "Free Serial Port Monitor" to debug my setup. This will let you see the serial stream as it is sent to the Arduino. If you get to this point post your serial stream here and I'll see if it's right.

    ReplyDelete
    Replies
    1. 3 years later and 3 displays later I am returning to this blog to use your code again! I am now using 3000 Ws2811 RGB LEDs and I am using my arduino to trigger fireworks. I just wanted to thank you for inspiring me to create my first light show. All the best. Edward

      Delete
  6. Hi, I created a sequence but I can not start the sequence with arduino. How did you do? thanks

    ReplyDelete
    Replies
    1. All of my development has been on v2 so far, but it shouldn't be that much different. I chose the generic serial driver for Vixen, then I use the above Arduino code to act as the light controller. That should do it. Let me know if you got it working!

      Delete
  7. I created a water fountain show and wanted to run it with my Mac.I searched three months and then found your Christmas show.I never knew you could run Windows on a Mac. That would let me run vixen. What size memory do you have on your Mac? What version of Windows do you run?

    ReplyDelete
    Replies
    1. Yup, in fact, Macs run Windows better than most PCs. I have run Windows 7 on 2006, 2009, and 2013 MacBook Pros. Apple added the support when they went to Intel processors. It's easy to set up. Run the Bootcamp utility, pop in your Windows 7 disc, and follow the instructions from there. You will be left with a partitioned hard drive that can boot into OSX or into Win7. There are plenty of tutorials online, just search "Windows 7 Bootcamp." Any Mac that can Bootcamp (2006+) should run Windows 7 fine. Good luck in your project! Will be interested in checking it out!

      Delete
  8. Thanks for helping me!
    What memory size did you partition for your windows?
    So I have to run Windows boot camp at the same time I run the Arduino software?
    So I need to get Parallels Desktop for Mac?

    ReplyDelete
  9. Happy to help! I usually give Windows at least 50GB. You use the boot camp utility to setup the windows partition and install Windows onto that partition. Then the Mac can physically boot into Windows or OSX. Once in Windows, you can install Arduino, Vixen, and any other Windows software you want. Parallels adds another layer of complexity and you don't necessarily need it. Parallels adds the ability to boot the Windows partition as a virtual machine while still inside of OSX. So you won't have to reboot to get to Windows, it just runs in its own OSX window. The downsides are it is slower than rebooting into Windows, it adds another layer between you and your hardware (Arduino), and it costs money. I wouldn't mess with it, just use bootcamp to install windows and reboot into it when you need it.

    I should also add, back up your stuff before you do this. If you're not careful during the install you could install Windows on top of the OSX partition instead of the Bootcamp partition. It pretty much wipes everything off of your Mac and you have to start all over again.

    Microsoft actually has a decent walkthrough:
    http://support.microsoft.com/kb/2647609

    ReplyDelete