Hi all
I am using the Razor IMU with an Arduino 1
thie is the code:
#include <SoftwareSerial.h>
SoftwareSerial softSerial(2, 3);
String buff;
String prueba;
int posicioncoma;
int posicioncomaaux;
int posasterisco;
String valor9;
String valor8;
String valor7;
String valor6;
String valor5;
String valor4;
String valor3;
String valor2;
String valor1;
String valor0;
void setup() {
Serial.begin(57600);
softSerial.begin(57600);
}
void loop() {
if(softSerial.available()){
while(softSerial.available()){
char in = (char)softSerial.read();
buff += in;
if(buff.indexOf('#')!=-1){
Serial.println(buff);
posicioncoma = buff.lastIndexOf(',');
posasterisco = buff.lastIndexOf('#');
valor9 = buff.substring(posicioncoma+1,posasterisco);
//Serial.println(valor9);
posicioncomaaux = buff.lastIndexOf(',',posicioncoma-1);
valor8 = buff.substring(posicioncomaaux+1,posicioncoma);
//Serial.println(valor8);
posicioncoma = buff.lastIndexOf(',',posicioncomaaux-1);
valor7 = buff.substring(posicioncoma+1,posicioncomaaux);
//Serial.println(valor7);
posicioncomaaux = buff.lastIndexOf(',',posicioncoma-1);
valor6 = buff.substring(posicioncomaaux+1,posicioncoma);
//Serial.println(valor6);
posicioncoma = buff.lastIndexOf(',',posicioncomaaux-1);
valor5 = buff.substring(posicioncoma+1,posicioncomaaux);
//Serial.println(valor5);
posicioncomaaux = buff.lastIndexOf(',',posicioncoma-1);
valor4 = buff.substring(posicioncomaaux+1,posicioncoma);
//Serial.println(valor4);
posicioncoma = buff.lastIndexOf(',',posicioncomaaux-1);
valor3 = buff.substring(posicioncoma+1,posicioncomaaux);
//Serial.println(valor3);
posicioncomaaux = buff.lastIndexOf(',',posicioncoma-1);
valor2 = buff.substring(posicioncomaaux+1,posicioncoma);
//Serial.println(valor2);
posicioncoma = buff.lastIndexOf(',',posicioncomaaux-1);
valor1 = buff.substring(posicioncoma+1,posicioncomaaux);
//Serial.println(valor1);
posicioncomaaux = buff.lastIndexOf(',',posicioncoma-1);
valor0 = buff.substring(posicioncomaaux+1,posicioncoma);
//Serial.println(valor0);
buff="";
}
}
}
}
The problem is that i obtain a String like that. I can also separate these numbers of the String and convert them to In but the main problem is that i have no idea about what these numbers mean.
&34,56,23,56,12,-34,-67,34,-76#
I tried to rotate the imu in one axis and some number changes, but these number that changes movimg one axis also change moving another.
Could someone help me to know how to obtain the pitch, yaw and roll angles instead of these?
Thanks in advance