Pages: 1 [2]   Go Down
Author Topic: need help in codes!  (Read 2360 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 40
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

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

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

Pages: 1 [2]   Go Up
Jump to: