Results 1 to 2 of 2

Thread: Vixen + Arduino+ Relay + Pixel HELP!

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2018
    Posts
    1
    Post Thanks / Like

    Default Vixen + Arduino+ Relay + Pixel HELP!

    Hey,

    Does anyone have a working arduino code that accounts for both relays and pixels? I'm new to vixen and just can't seem to manage to integrate them both!
    Thanks!!

  2. #2
    Join Date
    Dec 2016
    Location
    Hicksville, New York
    Posts
    102
    Post Thanks / Like

    Default Re: Vixen + Arduino+ Relay + Pixel HELP!

    Pretty sure you do not need Arduino to control pixels. You will need a separate controller. There must be a reason why no one has done a controller for pixels with Arduino. Probably because of efficiency. You can add the Generic Serial for the Arduino in Vixen for the relays which is what I did. Then add the pixel controller. If you have a pi, you can get the Falcon Pi Hat for $35 to run your pixels. (If you don't have a lot.) I would use Falcon Pi Player if you have a pi laying around to control the Arduino and the Hat (For Pixels.)


    For the Arduino, I am using this code to communicate with Vixen and the relays. Just change the code for the mega or Uno. Then your channel count and what pins you are using.

    Code:
    #define MEGA_VIXEN
    //#define UNO_VIXEN
    
    #ifdef MEGA_VIXEN
      #define MAX_CHANNELS 8
      //int channels[MAX_CHANNELS] = {2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53};
      int channels[MAX_CHANNELS] = {2,3,4,5,6,7,8,9};
    #endif
    
    #ifdef UNO_VIXEN
      #define MAX_CHANNELS 18
      int channels[MAX_CHANNELS] = {2,3,4,5,6,7,8,9,10,11,12,13,A0,A1,A2,A3,A4,A5};
    #endif
    
    #define TimeOut 5000L  //time out of 5 seconds for serial data check.
    int incomingByte[MAX_CHANNELS];
    unsigned long time_check = 0;  // Used to check time if  Vixen data received.
    
    void setup()
    {
      int i;
      int j;
      Serial.begin(9600); // set up Serial at 9600 bps
    
      for ( i = 0; i < MAX_CHANNELS; i ++ )  pinMode(channels[i], OUTPUT);
    time_check = millis();  //get the time.
    }
    
    void loop()
    {
      int i;
      int j;
      if (Serial.available() >= MAX_CHANNELS)
      {
        
        for (i=0; i < MAX_CHANNELS; i ++) {    incomingByte[i] = Serial.read();
           if (incomingByte[i] > 0) time_check = millis();  //get the time.
        }
      }
    
      for (i = 0; i < MAX_CHANNELS; i ++ )    analogWrite(channels[i], incomingByte[i]);
      if (millis() - time_check > TimeOut) {
         //Turn all lights on
            for (j=0; j < MAX_CHANNELS; j++) {
              incomingByte[j] = 255;
            }
      }
    }
    Here is a little diagram map of what I am trying to say.
    Arduino and Pixels.png
    Last edited by Spankyty; 01-31-2019 at 09:45 PM. Reason: Added Picture

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •