Introduction: Christmas Light Show
So i have finally got my christmas light show complete and stable.
i will be giving the code for the Arduino and the Physical electrical setup now.
if you need more on how to setup vixen 3 and anything else send me a message and i will get the rest of it up.
this year i have been merging RGBs into the code but that will have to be later since i am still working out the kinks. if you know how to keep the code i have with the test lights and the random mode and somehow add the RGB code into it please send me your ideas.
Step 1: The Code
So this is the code it is very simple and works great just read through the code and inside the coding it will explain itself. Just adapt the code for what you are using it for. You need the Arduino program you can get it here @ Arduino. (update): I forgot to tell you in order to get this to work with vixen you need to open vixen and change the port settings to send a header from vixen to stop random mode and start your sequence. just put this ~! in the header.
just copy and paste or download
// This was writen by Danlarocco. This is for 24SSRs and arduino Mega but it can be adapted to any Arduino.
// To adapt the code to your case, just change this top section, with the #define lines. // Includes the watchdog timer library #include
// This sets how many channels will vixen be sending. Can be set to any number from 1 to 48 for Arduino Mega, and 1 to 18 for Arduino Uno.
#define CHANNEL_COUNT 24
// speed for the com port for talking with vixen. From 9600 to 115200. Use the same speed as set in Vixen.
#define VIXEN_COM_SPEED 57600
// Timeout waiting for serial input before going to random mode (in milliseconds).
#define TIME_OUT 10000
// If the relays turn On and Off opposite to Vixen sequence.
#define NOT_INVERTED 0
#define INVERTED 1
#define MODE NOT_INVERTED
// which pins control which channels
// You can change these assignment to use different pins. I found that pin 13,20, and 21 dont work on my mega. They seem to stay on forever.
// DO NOT use pings 0 and 1, as those are for the serial port to talk to the computer.
#define CH01 2
#define CH02 3
#define CH03 4
#define CH04 5
#define CH05 6
#define CH06 7
#define CH07 8
#define CH08 9
#define CH09 10
#define CH10 11
#define CH11 12
#define CH12 32
#define CH13 33
#define CH14 34
#define CH15 22
#define CH16 23
#define CH17 24
#define CH18 25
#define CH19 26
#define CH20 27
#define CH21 28
#define CH22 29
#define CH23 30
#define CH24 31
int channels[] = {CH01,CH02,CH03,CH04,CH05 ,CH06,CH07,CH08,CH09, CH10,CH11,CH12,CH13,CH14,CH15,CH16,CH17,CH18,CH19,CH20,CH21,CH22,CH23,CH24};
int incomingByte[CHANNEL_COUNT];
int i = 0;
// Loop counter volatile unsigned long timer_a = 0;
// new line
//setup the pins/ inputs & outputs void setup(){
// enable the watchdog timer with a time of 1 second. If the board freezes, it will reset itself after 1 second. wdt_enable(WDTO_1S);
// specifically for the UNO sei();
// initalize PWM Channels / Pins for (i=0; i < CHANNEL_COUNT; i++){ pinMode(channels[i], OUTPUT); }
// set all the realys to off to start with if (MODE == NOT_INVERTED) { for (i=0; i < CHANNEL_COUNT; i++){ digitalWrite(channels[i], LOW);
} }
else { for (i=0; i < CHANNEL_COUNT; i++){ digitalWrite(channels[i], HIGH); } }
testSequence();
// set up Serial according to the speed defined above.
Serial.begin(VIXEN_COM_SPEED); }
void loop() { if (Serial.available() >= (CHANNEL_COUNT+2)) { wdt_reset();
// resets the watchdog
timer_a = millis ();
// new line
int uno = Serial.read(); if (uno == 126){ int dos = Serial.read(); if (dos == 33){ for (i=0; i < CHANNEL_COUNT; i++) {
// read each byte
incomingByte[i] = Serial.read(); } if (MODE == NOT_INVERTED) { for (i=0; i < CHANNEL_COUNT; i++){ int value = incomingByte[i]; if (value <= 127) { digitalWrite(channels[i], LOW); } else { digitalWrite(channels[i], HIGH); } } } else { for (i=0; i < CHANNEL_COUNT; i++){ int value = incomingByte[i]; if (value < 127) { digitalWrite(channels[i], HIGH); } else { digitalWrite(channels[i], LOW); } } }
} } }
// Random mode code. Random mode starts if no serial input has been received in TIME_OUT millisenconds else { wdt_reset();
// resets the watchdog
unsigned long diff = millis() - timer_a; if (diff >= TIME_OUT) { timer_a = millis (); int random_a = 0; for (i=0; i < CHANNEL_COUNT; i++){ random_a = random(0, 2); if (random_a == 0) { digitalWrite(channels[i], LOW); } else { digitalWrite(channels[i], HIGH); } } } } }
void testSequence(){
if (MODE == NOT_INVERTED) { for (i=0; i < CHANNEL_COUNT; i++){ wdt_reset();
// resets the watchdog
digitalWrite(channels[i], HIGH); delay (500); digitalWrite(channels[i], LOW); } }
else { for (i=0; i < CHANNEL_COUNT; i++){ wdt_reset(); // resets the watchdog digitalWrite(channels[i], LOW); delay (500); digitalWrite(channels[i], HIGH); } } }
Attachments
Step 2: The Wiring Is a Bit Difficult
I used 20 gauge solid wire to wire the Arduino to the relays and ground.Yellow wire is for the data pins and green for the ground and black for 5v.
Step 3: The SSRs
the solid state relays are simple to setup.
on the input side the wires from the Arduino
on the relay side the white wire comes in from the plug and daisy chains from each relay on the left side and then the output will come out and the to the plug.
the black wire from the plug will be split and go to each outlet.
now i am no electrician but i have done this for 2 years now and it works. but if someone has a better way please message me.
the Green wire come out of the plug and goes to ground bar from the ground bar to each outlet.
i did wire a few outlets that dont go to the relays
Step 4: The Cover
i put all of this into a box.