Go Down

Topic: Troubleshooting data communication between Master & Slave Arduinos using PS2X, E (Read 786 times) previous topic - next topic


Hi guys!  I'm trying to use EasyTransfer for sending arrays of bytes to another Arduino.  I've had no problem with the examples from EasyTransfer utilizing the random LED blinking with serial at 115200, even got the PS2X controller controlling the LED.  But when I modified the code to send 8 arrays of 24 bytes, and more specifically on the Slaves I convert one of the arrays of 24 bytes which represent rgb values per "pixel" for 8 pixels, into rgb values for 86 LEDs (the pixels have between 11 and 10 LEDs each).  I am not getting any color changing, the code attached below should turn all the LEDs on when a controller button is held/pressed? and off when another button is pressed.



Any suggestions?  I'm having a heck of a time!


Code: [Select]
byte BOX1[23]; //24 bytes to assign R,G,B values to LEDs
You can't store 24 bytes in a 23 element array.

Code: [Select]
  if(ps2x.NewButtonState(PSB_BLUE))            //will be TRUE if button was JUST pressed OR released
             for(int i = 0; i< 24; i++){ //Changes BOX 1 Array to 255 (on) aka white
                mydata.BOX1[i]=ON; //Set data in EasyTransfer Struct

  if(ps2x.ButtonPressed(PSB_RED))            //will be TRUE if button was JUST pressed OR released
             for(int i = 0; i< 24; i++){  //Changes BOX 1 Array to 0 (off) aka black
                mydata.BOX1[i]=OFF; //Set data in EasyTransfer Struct

You are populating the array with 24 identical values when a switch is pressed. Why? Seems to me that 1 value would be sufficient.

Only the BOX1 member of the structure is valued. Why is that? Sending a 192 byte structure containing 1 byte of data seems like a waste.
The art of getting good answers lies in asking good questions.


Thanks for noticing my error in the Array.  I thought the array counted from 0 when length is declared in []. 

Also the simple data is for testing purposes. Once I get this working, it will be 3 bytes per pixel, each byte representing an R, G, B value for the pixels on the slave side.  This is why right now it might seem dumb, but eventually that simple data won't be soo simple.

I will try changing the array numbers and see if that helps.


Thanks for noticing my error in the Array.  I thought the array counted from 0 when length is declared in [].

The array element count starts from zero but the value in the brackets is the number of elements needed not the number of the last element of the array.
Don't PM me for help as I will ignore it.


Unfortunately this does not help the main problem.  Somehow my data is never making it to the LPD8806 strips.

Go Up