Hello!! everyone i almost new in arduino i try to make a 6dof the code i have work whit a program that
send ascii code in the seria but the one i whant to work sen binary code
here a example of the code i recive in the serial the servo coresponding to each byte = serv1 serv2 serv3 serv4 serv5 serv6
binary code recive in the serial = “AB” byte1 byte2 byte3 byte4 byte5 byte6 byte7 0x0D
scale= 0 to 250 in all
Here the code for the ascii:
void loop() // the main loop where it all happens
{
if (Serial.available() > 0) { // Checks if anything in the serial buffer
j1 = Serial.read(); // Read a serial byte
if (j1 == 'AB'){ // Found the reading for "Pitch"
delay (5); // It seems to need a delay here
pitch = (Serial.read()); // first digit of the data
//pitch += char(Serial.read()); // Second digit and so-on
//pitch += char(Serial.read());
//pitch += char(Serial.read());
//pitch += char(Serial.read());
//pitch += char(Serial.read());
if (pitch != pitchold){ // checks to see if its different to the "old" reading
char carray[7]; //converting a string to number sequence
pitch.toCharArray(carray, sizeof(carray)); //converting string to number sequence
int n = atoi(carray); //converting string to number sequence
n = map(n, -250, 250, 0, 179); //Maps the readings to the servo
myservopitch.write(n); //Sends the data to servo
pitchold = pitch; // Writes the current reading to the "old" string.
} // end of it's a different reading section
} // end of "found A" section
I think the error here is the convertion i dont know :~
I appreciated any help!!!
Thanks!!!