Go Down

Topic: need help in codes! (Read 2738 times) previous topic - next topic

gr33nhorn

[code][#include <math.h>
#define Header 0xff  


byte *PosPtr;
byte ZeroPosArray[]={/* ID 0 ,  1 ,  2 ,  3 ,  4 ,  5 ,  6 ,  7 ,  8 ,   9,  10 ,  11 */
                         10 , 20 , 30 , 40 , 50 , 60 , 70 , 80 , 90 , 100, 111 , 120
                   };                                                                       //initial positions.
                   
byte WalkPosArray[5][12]={/* ID 0 ,  1 ,  2 ,  3 ,  4 ,  5 ,  6 ,  7 ,  8 ,   9,  10 ,  11 */
                             {10 , 20 , 30 , 40 , 50 , 60 , 70 , 80 , 90 , 100, 110 , 120}, //Index:0 -ViaPoint_0
                             {20 , 30 , 40 , 50 , 60 , 70 , 80 , 90 ,100 , 110, 120 , 130}, //Index:1 -ViaPoint_1
                             {30 , 40 , 50 , 60 , 70 , 80 , 90 ,100 ,110 , 120, 130 , 140}, //Index:0 -ViaPoint_2
                             {40 , 50 , 60 , 70 , 80 , 90 ,100 ,110 ,120 , 130, 140 , 150}, //Index:0 -ViaPoint_3
                             {50 , 60 , 70 , 80 , 90 ,100 ,110 ,120 ,130 , 140, 150 , 160}  //Index:4 -ViaPoint_0
                        };
void setup()
 {
   Serial.begin(115200);
   byte LastID, Torque;
   LastID=11;
   Torque=4; //0~4
   PosPtr=ZeroPosArray;
   SyncPosSend(LastID,Torque,PosPtr);//initialise
   
   
     
 }
 
void loop()
{
}
void SyncPosSend(byte LastID, byte Torque ,byte *PosPtr)
{
 byte i, Checksum;
 i=0;
 Checksum=0;
 Serial.print(Header,BYTE);
 Serial.print((Torque<<5)|0x1f,BYTE);
 Serial.print(LastID+1,BYTE);
   for(i=0; i<=LastID; i++)
     {
       Serial.print(*(PosPtr+i),DEC);
       Checksum ^=*(PosPtr+i);
     }
     
 Checksum &=0x7f;
 Serial.print(Checksum,BYTE);
 
}

/code]

i  have added a 2dArray and is intended to access it after acessed zeroposarray[], so how am i going to access the multi array if i'm going to use the SyncPosSend() function to access it too?please enlighten me.

gr33nhorn

My question on C....say...i have a 2d array of [3][4].......how can i use the values in this array and dump into a function whereby it will calculate the average value in
  • [1] and
  • [2] and put back into a new 2d array?

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy