Pages: [1] 2   Go Down
Author Topic: Christmas Lights Control System -Arduino Mega - 16 Channel Relay Board  (Read 22148 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 1
Posts: 41
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I hope this is the right area to share this.

Occasionally in order to get myself motivated to finish an existing project I need to jump onto another project for a break.  In this case I’ve been trying to get motivated to finish up my latest robot project for some time now and just can’t seem to get it done.  So, I’ve started a new project which is fun and will be fairly easy to complete, a Christmas lights controller with synchronized music.  You can buy these kinds of systems but building it is really the fun part for me.

The intent is to use an Arduino Mega 2560 microcontroller board (http://arduino.cc/en/Main/ArduinoBoardMega ), a 16-Channel 12V Relay Module and the Vixen software package (http://vixenlights.com ).

Vixen is a .NET based software package that lets you create lighting sequences to music.  It has a plug-in architecture for developers to create custom plug-ins for outputting the data for the sequences in whatever format that is needed.  It also allows you to define the number of “channels” to control lights on.  Basically a channel can be thought of as a single string of lights.  You can perform various types of commands against each channel for each “frame” of the sequence.  The cool part is you can define the number of frames per second, so you might say I want 10 frames per second, this allows you to command each channel to do something different 10 times every second.

The arduino will be pumped data from the Vixen software, running on a PC, via a USB serial connection. This data will tell the Arduino which lights to turn on and off via the relay module for each frame of the sequence. The relay module will do this by turning power on and off to 16 separate 120V AC wall outlets.  In order to do things like have a string of lights be at half brightness the data from vixen will send the channel a value of 128 (the value range for a channel is 0-255 off-fully on), the arduino will then use PWM (pulse width modulation, nothing more than turning something on/off really fast) to flip the relay for that channel on/off fast enough to make the lights look like they are at half brightness.

I'm fairly sure the hardware part isn't going to be a big problem. More likely the use of the data coming from Vixen into the Arduino and controlling the relays at a fast speed will probably cause me the most trouble.

Here is my YouTube channel were I am posting videos of my progress: http://www.youtube.com/user/zparticle

Here are the first videos I have put up:

Christmas Lights Control System - Part 1 -
Christmas Lights Control System - Part 2-1 -
Christmas Lights Control System - Part 2-2 -
Christmas Lights Control System - Part 2-3 -
Christmas Lights Control System - Part 3-1 -
Christmas Lights Control System - Part 3-2 -
Christmas Lights Control System - Part 4-1 -

If you are wondering about the weird numbering it's because I don't have decent video editing software on my Windows machine and I don't want to deal with my Mac.  I welcome any ideas on improvements. I'm already getting prepared for the relays not being able to switch fast enough to do fades.  If that turns out to be the case I will continue the series with videos using dimming circuits with random phase TRIACs.

Oh, and if I'm using the wrong terminology in the videos, please let me know.
« Last Edit: December 17, 2013, 04:16:42 am by Coding Badly » Logged

Offline Offline
Newbie
*
Karma: 1
Posts: 41
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm up to part 7 now.  Light show is in the near future.

http://www.youtube.com/watch?v=O8RZFEsQImk&feature=youtu.be
Logged

Offline Offline
Newbie
*
Karma: 1
Posts: 41
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Here is the Arduino 1.0.1 code for controlling the lights via Vixen.  It also includes a random mode for when you just want the lights to do something without having to have a Vixen program running.

Code:
#define CHANNEL01  2
#define CHANNEL02  3
#define CHANNEL03  4
#define CHANNEL04  5
#define CHANNEL05  6
#define CHANNEL06  7
#define CHANNEL07  8
#define CHANNEL08  9
#define CHANNEL09  10
#define CHANNEL10  11
#define CHANNEL11  12
#define CHANNEL12  13
#define CHANNEL13  44
#define CHANNEL14  45
#define CHANNEL15  46
#define CHANNEL16  47

#define RANDOM_MODE_PININ 52
#define RANDOM_MODE_PINOUT 53
#define RANDOM_MODE_SPEED 1000

int channels[] = {CHANNEL01,CHANNEL02,CHANNEL03,CHANNEL04,CHANNEL05,CHANNEL06,CHANNEL07,CHANNEL08,CHANNEL09,
CHANNEL10,CHANNEL11,CHANNEL12,CHANNEL13,CHANNEL14,CHANNEL15,CHANNEL16};

#define CHANNEL_COUNT 16
#define VIXEN_COM_SPEED 57600
#define PC_COM_SPEED 57600

boolean startingVixen = true;

void setup()
{
  Serial.begin(PC_COM_SPEED);
  Serial1.begin(VIXEN_COM_SPEED);
 
  pinMode(CHANNEL01,OUTPUT);
  pinMode(CHANNEL02,OUTPUT);
  pinMode(CHANNEL03,OUTPUT);
  pinMode(CHANNEL04,OUTPUT);
  pinMode(CHANNEL05,OUTPUT);
  pinMode(CHANNEL06,OUTPUT);
  pinMode(CHANNEL07,OUTPUT);
  pinMode(CHANNEL08,OUTPUT);
  pinMode(CHANNEL09,OUTPUT);
  pinMode(CHANNEL10,OUTPUT);
  pinMode(CHANNEL11,OUTPUT);
  pinMode(CHANNEL12,OUTPUT);
  pinMode(CHANNEL13,OUTPUT);
  pinMode(CHANNEL14,OUTPUT);
  pinMode(CHANNEL15,OUTPUT);
  pinMode(CHANNEL16,OUTPUT);
 
  // set up the switch for Vixen or Random mode
  pinMode(RANDOM_MODE_PININ, INPUT);
  digitalWrite(RANDOM_MODE_PININ,HIGH); // turn on the internal pull-up resistor
  pinMode(RANDOM_MODE_PINOUT, OUTPUT);
 
  turnLightsOff(); 
}

void loop()
{
  if(digitalRead(RANDOM_MODE_PININ)==LOW){ // blink at random mode
    startingVixen=true;
    doRandomLights();
  }else{ // play from Vixen mode
    if(startingVixen==true)
      turnLightsOff();
    readFromVixen();
  }
}

void turnLightsOff()
{
  //turn them all off
  for(int channelIndex=0;channelIndex<16;channelIndex++){
    analogWrite(channels[channelIndex], 0);
  }
}

void doRandomLights()
{
    randomSeed(analogRead(0));
    Serial.println("Writting random values.");
    for(int channelIndex=0;channelIndex<CHANNEL_COUNT;channelIndex++){
      int randNumber = random(255);
      analogWrite(channels[channelIndex], randNumber);
      Serial.print(randNumber, DEC);
      Serial.print(",");
    }
    Serial.println("");
    delay(random(100,RANDOM_MODE_SPEED));
}

void outputToLights(unsigned char* buffer)
{
    for(int channelIndex=0;channelIndex<CHANNEL_COUNT;channelIndex++){
      analogWrite(channels[channelIndex], buffer[channelIndex]);
      Serial.print(buffer[channelIndex], DEC);
      Serial.print(",");
    }
    Serial.println("");
}

void readFromVixen()
{
  Serial.println("Waiting for data from Vixen.");
  startingVixen = false;
  char *footer="VIXEN_END";
  unsigned char buffer[CHANNEL_COUNT];
  char buffer2[CHANNEL_COUNT];
  int index=0;
  unsigned long time = millis();

  waitForVixenHeader();
  while (true) {
    int inByte = Serial1.read();
    if(inByte==-1){
      if(index==0 && millis()-time>1000) // we haven't read anything in a second
        return;
      continue;
    }
    time = millis();
    buffer[index] = inByte;
    buffer2[index] = inByte;
    buffer[index+1] = 0;
    buffer2[index+1] = 0;
    index++;
    if(index==9 && strcmp(footer,buffer2)==0){
      Serial.println(footer);
      return;
    }
    else if(index==CHANNEL_COUNT){
      outputToLights(buffer);
      index=0;
    }
  }
  Serial.println("");
}

void waitForVixenHeader()
{
  char *header="VIXEN_START";
  char buffer[12];
  int index = 0;
  unsigned long time = millis();

  while (true) {
    int inByte = Serial1.read();
    if(inByte==-1){
      if(index==0 && millis()-time>1000) // we haven't read anything in a second
        return;
      continue;
    }
    time = millis();
    buffer[index] = inByte;
    if(buffer[index]!=header[index]) {// not the right sequence restart
      index=-1;
    }
    buffer[index+1] = 0; // add null
    index++;
    if(index==11 && strcmp(header,buffer)==0){
      Serial.println(header);
      return;
    }
  }
}



Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 548
Posts: 46013
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
  pinMode(CHANNEL01,OUTPUT);
  pinMode(CHANNEL02,OUTPUT);
  pinMode(CHANNEL03,OUTPUT);
  pinMode(CHANNEL04,OUTPUT);
  pinMode(CHANNEL05,OUTPUT);
  pinMode(CHANNEL06,OUTPUT);
  pinMode(CHANNEL07,OUTPUT);
  pinMode(CHANNEL08,OUTPUT);
  pinMode(CHANNEL09,OUTPUT);
  pinMode(CHANNEL10,OUTPUT);
  pinMode(CHANNEL11,OUTPUT);
  pinMode(CHANNEL12,OUTPUT);
  pinMode(CHANNEL13,OUTPUT);
  pinMode(CHANNEL14,OUTPUT);
  pinMode(CHANNEL15,OUTPUT);
  pinMode(CHANNEL16,OUTPUT);

You put these numbers in an array. Use a for loop!

Logged

Offline Offline
Newbie
*
Karma: 1
Posts: 41
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yep, i put them in the array so I could easily rearrange the channels.  I get you point though. smiley
Logged

Offline Offline
Newbie
*
Karma: 1
Posts: 41
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Here is an update to the code.  I've added a power on self test that runs through each channel one at a time turning it on for 1.5 seconds.

Code:
#define CHANNEL01  2
#define CHANNEL02  3
#define CHANNEL03  4
#define CHANNEL04  5
#define CHANNEL05  6
#define CHANNEL06  7
#define CHANNEL07  8
#define CHANNEL08  9
#define CHANNEL09  10
#define CHANNEL10  11
#define CHANNEL11  12
#define CHANNEL12  13
#define CHANNEL13  44
#define CHANNEL14  45
#define CHANNEL15  46
#define CHANNEL16  47

#define RANDOM_MODE_PININ 52
#define RANDOM_MODE_PINOUT 53
#define RANDOM_MODE_SPEED 1000

int channels[] = {CHANNEL01,CHANNEL02,CHANNEL03,CHANNEL04,CHANNEL05,CHANNEL06,CHANNEL07,CHANNEL08,CHANNEL09,
CHANNEL10,CHANNEL11,CHANNEL12,CHANNEL13,CHANNEL14,CHANNEL15,CHANNEL16};

#define CHANNEL_COUNT 16
#define VIXEN_COM_SPEED 57600
#define PC_COM_SPEED 57600

boolean startingVixen = true;

void setup()
{
  Serial.begin(PC_COM_SPEED);
  Serial1.begin(VIXEN_COM_SPEED);
 
  pinMode(CHANNEL01,OUTPUT);
  pinMode(CHANNEL02,OUTPUT);
  pinMode(CHANNEL03,OUTPUT);
  pinMode(CHANNEL04,OUTPUT);
  pinMode(CHANNEL05,OUTPUT);
  pinMode(CHANNEL06,OUTPUT);
  pinMode(CHANNEL07,OUTPUT);
  pinMode(CHANNEL08,OUTPUT);
  pinMode(CHANNEL09,OUTPUT);
  pinMode(CHANNEL10,OUTPUT);
  pinMode(CHANNEL11,OUTPUT);
  pinMode(CHANNEL12,OUTPUT);
  pinMode(CHANNEL13,OUTPUT);
  pinMode(CHANNEL14,OUTPUT);
  pinMode(CHANNEL15,OUTPUT);
  pinMode(CHANNEL16,OUTPUT);
 
  // set up the switch for Vixen or Random mode
  pinMode(RANDOM_MODE_PININ, INPUT);
  digitalWrite(RANDOM_MODE_PININ,HIGH); // turn on the internal pull-up resistor
  pinMode(RANDOM_MODE_PINOUT, OUTPUT);
 
  turnLightsOff(); 
  powerOnSelfTest();
}

// !!!! note the PWM values that need to be sent to the relay board are reversed from the
// values comming in from Vixen.  Vixen 0-255 (off-on), Relays 255-0 (off-on)

void loop()
{
  if(digitalRead(RANDOM_MODE_PININ)==LOW){ // blink at random mode
    startingVixen=true;
    doRandomLights();
  }else{ // play from Vixen mode
    if(startingVixen==true)
      turnLightsOff();
    readFromVixen();
  }
}

void powerOnSelfTest()
{
    Serial.println("Power on self test running.");
    for(int channelIndex=0;channelIndex<CHANNEL_COUNT;channelIndex++){
      analogWrite(channels[channelIndex], 0); // turn on one channel at a time
      delay(1500); // wait 1.5 seconds
      analogWrite(channels[channelIndex], 255);
    }
    turnLightsOff();
}

void turnLightsOff()
{
  //turn them all off
  for(int channelIndex=0;channelIndex<16;channelIndex++){
    analogWrite(channels[channelIndex], 255);
  }
}

void doRandomLights()
{
    randomSeed(analogRead(0));
    Serial.println("Writting random values.");
    for(int channelIndex=0;channelIndex<CHANNEL_COUNT;channelIndex++){
      int randNumber = random(255);
      randNumber = map(randNumber, 0, 255, 255, 0);
      analogWrite(channels[channelIndex], randNumber);
      Serial.print(randNumber, DEC);
      Serial.print(",");
    }
    Serial.println("");
    delay(random(100,RANDOM_MODE_SPEED));
}

void outputToLights(unsigned char* buffer)
{
    for(int channelIndex=0;channelIndex<CHANNEL_COUNT;channelIndex++){
      analogWrite(channels[channelIndex], buffer[channelIndex]);
      Serial.print(buffer[channelIndex], DEC);
      Serial.print(",");
    }
    Serial.println("");
}

void readFromVixen()
{
  Serial.println("Waiting for data from Vixen.");
  startingVixen = false;
  char *footer="VIXEN_END";
  unsigned char buffer[CHANNEL_COUNT];
  char buffer2[CHANNEL_COUNT];
  int index=0;
  unsigned long time = millis();

  waitForVixenHeader();
  while (true) {
    int inByte = Serial1.read();
    if(inByte==-1){
      if(index==0 && millis()-time>1000) // we haven't read anything in a second
        return;
      continue;
    }
    time = millis();
    int lightByte = map(inByte, 0, 255, 255, 0);
    buffer[index] = lightByte;
    buffer2[index] = inByte;
    buffer[index+1] = 0;
    buffer2[index+1] = 0;
    index++;
    if(index==9 && strcmp(footer,buffer2)==0){
      Serial.println(footer);
      return;
    }
    else if(index==CHANNEL_COUNT){
      outputToLights(buffer);
      index=0;
    }
  }
  Serial.println("");
}

void waitForVixenHeader()
{
  char *header="VIXEN_START";
  char buffer[12];
  int index = 0;
  unsigned long time = millis();

  while (true) {
    int inByte = Serial1.read();
    if(inByte==-1){
      if(index==0 && millis()-time>1000) // we haven't read anything in a second
        return;
      continue;
    }
    time = millis();
    buffer[index] = inByte;
    if(buffer[index]!=header[index]) {// not the right sequence restart
      index=-1;
    }
    buffer[index+1] = 0; // add null
    index++;
    if(index==11 && strcmp(header,buffer)==0){
      Serial.println(header);
      return;
    }
  }
}

Logged

Offline Offline
Newbie
*
Karma: 1
Posts: 41
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

BTW the project is done, there will be new videos up on youtube tonight.
Logged

Offline Offline
Newbie
*
Karma: 1
Posts: 41
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Here is the last of the project build videos, will have another video or two of it running with my lights later.

http://www.youtube.com/watch?v=kqm_ts3lvGU&feature=youtu.be
Logged

Offline Offline
Newbie
*
Karma: 1
Posts: 41
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Sorry for constantly updating this thread but I keep making code changes.

Code:
// which pins control which channels
#define CHANNEL01  2
#define CHANNEL02  3
#define CHANNEL03  4
#define CHANNEL04  5
#define CHANNEL05  6
#define CHANNEL06  7
#define CHANNEL07  8
#define CHANNEL08  9
#define CHANNEL09  10
#define CHANNEL10  11
#define CHANNEL11  12
#define CHANNEL12  13
#define CHANNEL13  44
#define CHANNEL14  45
#define CHANNEL15  46
#define CHANNEL16  47

// Which pins is the random/Vixen mode switch using
#define RANDOM_MODE_PININ 52
#define RANDOM_MODE_PINOUT 53
#define RANDOM_MODE_SPEED 5000

int channels[] = {CHANNEL01,CHANNEL02,CHANNEL03,CHANNEL04,CHANNEL05,CHANNEL06,CHANNEL07,CHANNEL08,CHANNEL09,
CHANNEL10,CHANNEL11,CHANNEL12,CHANNEL13,CHANNEL14,CHANNEL15,CHANNEL16};

// how many channel will vixen be sending
#define CHANNEL_COUNT 16

// speed for the com port for talking with vixen
#define VIXEN_COM_SPEED 57600

// speed for talking with the serial monitor in the IDE
#define PC_COM_SPEED 57600

// setup your choice of dimming values or just on/off values
// the relays don't seem to be able to dim the lights so it looks
// like I will have to build dimmer circuits for next year. The
// doesn't change, just have to remove the relay bord and replace
// it with a dimmer circuit for each relay.
#define MODE_DIMMING 0
#define MODE_FULL 1
#define MODE MODE_FULL

boolean startingVixen = true;

void setup()
{
  Serial.begin(PC_COM_SPEED);
  Serial1.begin(VIXEN_COM_SPEED);
 
  // set the channel pins to output mode
  for(int channelIndex=0;channelIndex<CHANNEL_COUNT;channelIndex++){
    pinMode(channels[channelIndex],OUTPUT);
  }
 
  // set up the switch for Vixen or Random mode
  pinMode(RANDOM_MODE_PININ, INPUT);
  digitalWrite(RANDOM_MODE_PININ,HIGH); // turn on the internal pull-up resistor
  pinMode(RANDOM_MODE_PINOUT, OUTPUT);
 
  turnLightsOff(); 
  powerOnSelfTest();
}

// !!!! note the PWM values that need to be sent to the relay board are reversed from the
// values comming in from Vixen.  Vixen 0-255 (off-on), Relays 255-0 (off-on)
void loop()
{
  if(digitalRead(RANDOM_MODE_PININ)==LOW){ // blink at random mode
    startingVixen=true;
    doRandomLights();
  }else{ // play from Vixen mode
    if(startingVixen==true)
      turnLightsOff();
    readFromVixen();
  }
}

void powerOnSelfTest()
{
    Serial.println("Power on self test running.");
    for(int channelIndex=0;channelIndex<CHANNEL_COUNT;channelIndex++){
      Serial.print("Channel: ");
      Serial.println(channelIndex+1,DEC);
      analogWrite(channels[channelIndex], 0); // turn on one channel at a time
      delay(500); // wait .5 seconds
      analogWrite(channels[channelIndex], 255);
    }
    turnLightsOff();
}

void turnLightsOff()
{
  //turn them all off
  for(int channelIndex=0;channelIndex<16;channelIndex++){
    analogWrite(channels[channelIndex], 255);
  }
}

void doRandomLights()
{
    randomSeed(analogRead(0));
    Serial.println("Writting random values.");
    for(int channelIndex=0;channelIndex<CHANNEL_COUNT;channelIndex++){
      if(MODE == MODE_DIMMING)
      {
        int randNumber = random(255);
        randNumber = map(randNumber, 0, 255, 255, 0);
        analogWrite(channels[channelIndex], randNumber);
        Serial.print(randNumber, DEC);
        Serial.print(",");
      }
      else // not dimming, just on or off
      {
        int randNumber = random(0, 255);
        randNumber = map(randNumber, 0, 255, 255, 0);
        if(randNumber<=128)
          analogWrite(channels[channelIndex], 0);
        else
          analogWrite(channels[channelIndex], 255);
        Serial.print(randNumber, DEC);
        Serial.print(",");
      }
    }
    Serial.println("");
    delay(random(100,RANDOM_MODE_SPEED));
}

void outputToLights(unsigned char* buffer)
{
    for(int channelIndex=0;channelIndex<CHANNEL_COUNT;channelIndex++){
      analogWrite(channels[channelIndex], buffer[channelIndex]);
      Serial.print(buffer[channelIndex], DEC);
      Serial.print(",");
    }
    Serial.println("");
}

void readFromVixen()
{
  Serial.println("Waiting for data from Vixen.");
  startingVixen = false;
  char *footer="VIXEN_END";
  unsigned char buffer[CHANNEL_COUNT];
  char buffer2[CHANNEL_COUNT];
  int index=0;
  unsigned long time = millis();

  waitForVixenHeader();
  while (true) {
    int inByte = Serial1.read();
    if(inByte==-1){
      if(index==0 && millis()-time>1000) // we haven't read anything in a second
        return;
      continue;
    }
    time = millis();
    int lightByte = map(inByte, 0, 255, 255, 0);
    buffer[index] = lightByte;
    buffer2[index] = inByte;
    buffer[index+1] = 0;
    buffer2[index+1] = 0;
    index++;
    if(index==9 && strcmp(footer,buffer2)==0){
      Serial.println(footer);
      return;
    }
    else if(index==CHANNEL_COUNT){
      outputToLights(buffer);
      index=0;
    }
  }
  Serial.println("");
}

void waitForVixenHeader()
{
  char *header="VIXEN_START";
  char buffer[12];
  int index = 0;
  unsigned long time = millis();

  while (true) {
  int inByte = Serial1.read();
    if(inByte==-1){
      if(index==0 && millis()-time>1000) // we haven't read anything in a second
        return;
      continue;
    }
    time = millis();
    buffer[index] = inByte;
    if(buffer[index]!=header[index]) {// not the right sequence restart
      index=-1;
    }
    buffer[index+1] = 0; // add null
    index++;
    if(index==11 && strcmp(header,buffer)==0){
      Serial.println(header);
      return;
    }
  }
}
Logged

Offline Offline
Newbie
*
Karma: 1
Posts: 41
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I've had a few questions from some folks about the project wiring so a made a little video which I'll be uploading to youtube shortly to try to explain it.  Here is a little textual explanation that covers the most important points.  I don't do very well trying to explain things verbally sometimes, which you will notice if you watch the new video. smiley-razz

Basically the key to the project is this:

There are 3 common power bus lines. Ground, Positive and Negative. 

The electrical sockets all have their positive terminals connected together on the common positive bus.

The electrical sockets all have their ground terminals connected on the common ground bus. 

Each electrical socket has its negative terminal connected to one of the relays with the center screw terminal of the relay.

The third screw terminal (common open of the relay) of every relay is connected to the common negative bus.

When a relay closes it connects the electrical socket's negative terminal to the common negative bus thus allowing power to flow through the circuit for that individual electrical socket, causing the lights plugged into that socket to light up.

There are two power sources for the project.  The power source supplying power to the electrical sockets (the orange plug in the project) and the power supply that is powering the relay board and the Arduino board (that little HP power supply in the project).
Logged

Offline Offline
Newbie
*
Karma: 1
Posts: 41
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Anyone know if it is possible to replace the mechanical relays on the relay board with equivalent solid state relays (non-zero crossing) and if so what would the part number be for the SSRs?
« Last Edit: December 17, 2013, 04:16:58 am by Coding Badly » Logged

Offline Offline
Newbie
*
Karma: 1
Posts: 41
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Well I've pretty much come to the conclusion that even if I could find SSRs to replace the mechanical relays I still wouldn't get the dimming control I want.  For now I'm leaving the project as is, it works and is a good start for me.  That gives me a year to figure out how to create dimming circuits, lol.  The project was fun though. smiley
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Will the latest code work on a arduino uno but using only 13 channels?
Logged

Offline Offline
Newbie
*
Karma: 1
Posts: 41
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i can't think of any reason it wouldn't.  If you have issues let me know.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I commented on your Youtube video regarding running your sketch using (Just a USB) I still could not make it work by removing the serial.print and changing Serial1 to Serial.  I decided to write my own which only has one problem which only has one problem I was hoping you might help me with.  All the lights turn on and my "squares" in vixen only turn them off.  So it actually is working opposite  of how it should.  I did put in your code that turns all the lights off and the powerOnSelfTest and all that works fine.  It only screws up when vixen runs.

Code:
/// Channel_Count must be > 0 and < 17
int Channel_Count = 16;
int Pin_Offset = 2;

void setup(){
    Serial.begin(57600);

    for (int channel_index=Pin_Offset; channel_index < Channel_Count + Pin_Offset; channel_index++)
    {
        pinMode(channel_index, OUTPUT); //set the pin mode for each channel
       
        //test the channels to see if they are all working
        analogWrite(channel_index, 0); //turn channel at [channel_index] on
        delay(250); // wait
        analogWrite(channel_index, 255); //turn channel at [channel_index] off
    }

    Serial.print("System Ready");
    turn_all_lights_off(); //All the lights come on by default, turn them off
}

void loop()
{
    if (Serial.available() >= Channel_Count)
    {
        for (int channel_index=Pin_Offset; channel_index < Channel_Count + Pin_Offset; channel_index++)
        {
            analogWrite(channel_index, Serial.read());
        }
   
        Serial.println("System Ready");
    }
}

//Force all the lights off
void turn_all_lights_off()
{
 
  for(int channel_index=Pin_Offset;channel_index<Channel_Count + Pin_Offset;channel_index++){
    analogWrite(channel_index, 255);
  }
}

Thank you so much for your help.  You did an Amazing job on your build!!!
Logged

Pages: [1] 2   Go Up
Jump to: