Pages: [1]   Go Down
Author Topic: Troubleshooting data communication between Master & Slave Arduinos using PS2X, E  (Read 282 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 14
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

http://www.northstreetlabs.org/OSfiles/BoxSlaveOne.ino

http://www.northstreetlabs.org/OSfiles/MasterBegin.ino

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

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 549
Posts: 46147
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
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:
  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.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 14
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Norfolk UK
Offline Offline
Edison Member
*
Karma: 52
Posts: 2214
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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.
« Last Edit: August 04, 2012, 11:15:23 am by Riva » Logged

Handle every stressful situation like a dog. If you can't eat it or hump it. Piss on it and walk away.

0
Offline Offline
Newbie
*
Karma: 0
Posts: 14
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Pages: [1]   Go Up
Jump to: