27.- App sends two values separated by commas. Arduino adds them up and returns the sum.
p40i_bluetooth_deslizador.aia (3.5 KB)
- App sends two comma separated values created by two Sliders.
70.3,60.4
- Arduino receives those values, separates them by comma, and adds them up.
Using Serial.println(addition) returns the sum
130.70
String texto;
String a ;
String b;
float suma = 0.0;
void setup() {
Serial.begin(9600);
Serial.setTimeout(200);
}
void loop() {
if(Serial.available()) {
// texto = Serial.readString();
// Serial.println(texto);
a = Serial.readStringUntil(',');
b = Serial.readStringUntil('\n');
suma = a.toFloat() + b.toFloat();
// Serial.println(a);
// Serial.println(b);
Serial.println(suma);
}
}
-
Clock1.TimerInterval = 100 and Serial.setTimeout (200) are important;

