The first reply on this thread gave me a link to a website that gives examples on how to parse which I've been trying to integrate into my code to make it work. Ive been using example 3 and 5.
Putting example 3 into my code, i ended up with this
float i;
float k;
float j;
float roll;
float pitch;
float yaw;
const byte numChars = 32;
char receivedChars[numChars];
boolean newData = false;
const float referenceVolts = 5.0; // the default reference on a 5-volt board
const int batteryPin = 0; // battery is connected to analog pin 0
void setup() {
Serial.begin(9600);
}
void loop() {
recvWithStartEndMarkers();
}
void recvWithStartEndMarkers() {
static boolean recvInProgress = false;
static byte ndx = 0;
char startMarker = '<';
char endMarker = '>';
char rc;
while (Serial.available() > 0) {
rc = Serial.read();
if (recvInProgress == true) {
if (rc != endMarker) {
receivedChars[ndx] = rc;
ndx++;
i = Serial.parseFloat();
j = Serial.parseFloat();
k = Serial.parseFloat();
roll = Serial.parseFloat();
pitch = Serial.parseFloat();
yaw = Serial.parseFloat();
Serial.println(i);
Serial.println(j);
Serial.println(k);
Serial.println(roll);
Serial.println(pitch);
Serial.println(yaw);
if (ndx >= numChars) {
ndx = numChars - 1;
}
}
else {
receivedChars[ndx] = '\0'; // terminate the string
recvInProgress = false;
ndx = 0;
newData = true;
}
}
else if (rc == startMarker) {
recvInProgress = true;
}
}
}
Im still running into errors of the code either not parsing the data or not using the parsed data in the math that follows it.