Pages: [1]   Go Down
Author Topic: Arduino and VixenLights programming issue  (Read 429 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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);
  }
}
« Last Edit: January 20, 2013, 10:49:56 pm by umobie » Logged

Pages: [1]   Go Up
Jump to: