Arduino XBee and LED Lighting Question

EL Wire/Tape/Panels, LEDs, pixels and strips, LCDs and TFTs, etc products from Adafruit

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
mattjames
 
Posts: 4
Joined: Thu Mar 20, 2014 6:37 pm

Arduino XBee and LED Lighting Question

Post by mattjames »

So I posted in the General help forum about a project I was going to do and now I am at a road block. So here is my setup.

2x Arduino Uno R3 (We'll call them Arduino1 and Arduino2)
2x SainSmart XBee Shield
2x XBee Pro Series 1 60mw
2x 75mm Bars - 12V Digital RGB LED Pixels

As of right now I have Vixen3 lighting software on one computer through USB controlling one strand of the pixels on Pins 2 and 3 on Arduino1 with no problems. I am having trouble sending the data from Arduino1 to Arduino2 with the XBee to recreate what is happening on Arduino1 without having to use another computer. I have posted the code that I am using to control the LEDs on Arduino1, most of the code is borrowed. I really could use some help on this one because my head hurts from banging it against the wall.

Code: Select all


#include "Adafruit_WS2801.h"    
#include "SPI.h"                                  
                       
#define DPIN 2                  
#define CPIN 3                  

int   PixelCount = 21;             

int   bugLevel  = 0;            

Adafruit_WS2801 strip = Adafruit_WS2801(21, DPIN, CPIN); 

void setup()
{
  delay(100);                     
  strip.begin();                
  strip.show();                 
 
  Serial.begin(115200);         


}


void loop()
{                                   
 
	if (Serial.available()>2)        
  {

    waitForVixenHeader();             

	
  	for (int pixCount=0; pixCount<PixelCount;pixCount++)     
    {
      int RGB[3];                                           
      for (int color = 0;color<3;color++)     
      {                       
        while (Serial.available() < 1)        
        {
          delay(10);
        }
        RGB[color] = Serial.read();           
      }                                       

      strip.setPixelColor(pixCount,RGB[0],RGB[1],RGB[2]);  
      
    }                                         
    strip.show();                                                 
  }                                           
}                                             

void waitForVixenHeader()
{


    char *header="VIXStart";
    char buffer[3];
    int index = 0;

    while (true) 
    {

        int inByte = Serial.read();
        if(inByte==-1)
        {
          continue;
        }
        
        buffer[index] = inByte;
        if(buffer[index]!=header[index])
        {            
            index=-1;                     
        }
        
        buffer[index+1] = 0;             
        index++;
        if(index==8)
        {
          return;
        }
    }
}


User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Arduino XBee and LED Lighting Question

Post by adafruit_support_rick »

Please don't double post

Locked
Please be positive and constructive with your questions and comments.

Return to “Glowy things (LCD, LED, TFT, EL) purchased at Adafruit”