Show Posts
Pages: [1]
1  Using Arduino / Interfacing w/ Software on the Computer / Arduino and VixenLights programming issue on: January 20, 2013, 09:15:35 pm
I am building a arduino based light control system using VixenLights.  Everything is working but in reverse.  I have a POST test that runs through every light at starup and that works fine but in my loop() It seems when Vixen starts it makes all the lights go on, and when I mark sections in vixen to turn lights on it turns them off.  I just need the system to work exactly opposite of the way it is.

Thanks in advance

Code:

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
        
        //POST test the channels to see if they are all working
        
        //this works fine
        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 some reason after this point all the lights are on and vixen turns them off
      //I need for the lights to be off and vixen to turn them on as initiated by the program
        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);
  }
}
2  Development / Other Hardware Development / Re: Christmas Lights Control System -Arduino Mega - 16 Channel Relay Board on: January 19, 2013, 12:57:50 pm
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!!!
Pages: [1]