yes i agree am totally wrong but really coding is not my thing , am sorry if i wrote stupid code and i wanted you to explain .
however i did another aproch and am getting data from my serial port but they r not correct .
can you check this code please
void setup(){
Serial.begin(9600);
delay(100);
Serial.print("reading.. ");
Serial.println();
}
void loop() {
readPacket();
}
void readPacket(){
// if serial has 18 bytes which what we need int he buffer my every packets contains 18 bytes
if (Serial.available() >= 18) {
// FIND MY START BIT
if (Serial.read()==0x7E)
// read the value we do not need out of the buffer
for(int i =0 ; i< 11 ; i++)
byte discard = Serial.read();
//which contains x value for my 12th byte and 13 byte
if(int i=12 )
{
int analogHigh = Serial.read( );
int analogLow = Serial.read();
x = analogLow + (analogHigh * 256);
Serial.println(x, DEC);
}
else
// he is for my y value for my 14th and 15 byte
if (int i=14) {
int analogHigh = Serial.read( );
int analogLow = Serial.read();
y = analogLow + (analogHigh * 256);
Serial.println(y, DEC);
Serial.flash ();
}
else
// here is for my z value
if (int i=16){
int analogHigh = Serial.read( );
int analogLow = Serial.read();
z = analogLow + (analogHigh * 256);
Serial.println(z, DEC);
Serial.flash ();
}
}
}