So I am defining this array
float Latest [8]= {0, 0, 0, 0, 0, 0, 0, 0}; // The string that comes from the processing serial
and then I have a function that receives a serial string from my tablet.
void DataSplit() // for the tablet string
{
String c = FromTablet;
// String c = FromTablet.remove(0,2);
String M1, M2, M3, M11, M12, M13, M5 , M6, M7;
//String M14;
String Time_To_Complete_Str;
int var = 0;
if (c[0] == 'g') { // if the command trigger word is detect
Serial.println(c.length()); // display start of message
for (unsigned int i = 1; i <= c.length(); i++) { // a for loop is set to run as many time as the # of characters in a string
if (c[i] == ' ') { // SPace is used for Separation
var++;
// Serial.println (var); // Everytime space is detected, the variable index is incread
}
if (var == 1) { // variable index one is used for base
M1 = M1 + c[i]; // characters are added as a string to represent base valu
}
if (var == 2) { ///ect....
M2 = M2 + c[i];
}
if (var == 3) { // ect...
M3 = M3 + c[i];
}
if (var == 4) { // ect...
M11 = M11 + c[i];
}
if (var == 5) { // ect...
M12 = M12 + c[i];
}
if (var == 6) { // ect...
M13 = M13 + c[i];
}
if (var == 7) { // ect...
M5 = M5 + c[i];
}
if (var == 8) { // ect...
M6 = M6 + c[i];
}
if (var == 9) { // ect...
M7 = M7 + c[i];
}
if (var == 10) { // ect...
Time_To_Complete_Str = Time_To_Complete_Str + c[i];
}
}
/// once these joints are done, variable index are set back to 0, you can add more index for horizontal wrist and gripper
GoTo_Ang[1] = M1.toFloat();
GoTo_Ang[2] = M2.toFloat();
GoTo_Ang[3] = M3.toFloat();
GoTo_Ang[11] = M11.toFloat();
GoTo_Ang[12] = M12.toFloat();
GoTo_Ang[13] = M13.toFloat();
GoTo_Ang[5] = M5.toFloat();
GoTo_Ang[6] = M6.toFloat();
GoTo_Ang[7] = M7.toFloat();
Tm = Time_To_Complete_Str.toFloat();
//Serial.println (Tm);
// Angle_Speed (GoTo_Ang[7], 360, 7);
//delay (3);
//EvBody_Go (GoTo_Ang[1], GoTo_Ang[2], GoTo_Ang[3],
// GoTo_Ang[11], GoTo_Ang[12], GoTo_Ang[13], GoTo_Ang[5], GoTo_Ang[6], Tm);
Latest [8] = (GoTo_Ang[1], GoTo_Ang[2], GoTo_Ang[3], GoTo_Ang[11], GoTo_Ang[12], GoTo_Ang[13], GoTo_Ang[5], GoTo_Ang[6]) ;
for (int i= 1; i<14; i++)
{
Serial.println (i);
Serial.println (Latest[i]);
}
for (int i= 1; i<14; i++)
{
Serial.println (i);
Serial.println (GoTo_Ang[i]);
}
//Mini_Steps (Latest, Tm);
var = 0;
//StepNo = 0;
} // if g end
}
when I print the GoTo_ang array all values are correct, but the "Latest " array is showing only zeros:
From the serial monitor:
FromTablet: g -27.1, -50.0, 22.9, 54.8, 77.7, 22.9, 1.8, -45.8, 0.0, 600.0);
64
1
0.00
2
0.00
3
0.00
4
0.00
5
0.00
6
0.00
7
0.00
8
-45.80
9
0.00
10
0.00
11
0.00
12
0.00
13
0.00
1
-27.10
2
-50.00
3
22.90
4
0.00
5
1.80
6
-45.80
7
0.00
8
0.00
9
0.00
10
0.00
11
54.80
12
77.70
13
22.90
Where am I going wrong? Thanks