Hallo,
As I am working on data transfer from a adxl over xbee ( from adxl to processing is working)
I like to read the serial data in a arduino to have them for controling a steppermotor.
the format is 123,45,0,etc. for x,y,z, etc.
Howe to read the serial string in the arduino ? Then i want to make int from the data and use them.
Any suggestions are welcome.
Enclosed the script from the arduino board with adxl.
Theo
int regAddress = 0x32; //first axis-acceleration-data register on the ADXL345
int x, y, z;
readFrom(DEVICE, regAddress, TO_READ, buff); //read the acceleration data from the ADXL345
//each axis reading comes in 10 bit resolution, ie 2 bytes. Least Significat Byte first!!
//thus we are converting both bytes in to one int
x = (((int)buff[1]) << 8) | buff[0];
y = (((int)buff[3]) << 8) | buff[2];
z = (((int)buff[5]) << 8) | buff[4];
//we send the x y z values as a string to the serial port
sprintf(str, "%d %d %d", x, y, z);
x = 0; // toegevoegd om x uit te schakelen???????
y = 0; // toegevoegd om y uit te schakelen???????
Serial.print(str);
Serial.print(10, BYTE);
//It appears that delay is needed in order not to clog the port
delay(15);
}