Hi everyone, this is my first post. I'm sorry for my English, I'm from South America. I'm programming this code, where I input 2 values in the serial port (x and y) to save them in two int variables.
int x;
int y;
#define PRINT(a) Serial.println(a);
void setup()
{
Serial.begin(9600);
Serial.setTimeout(10);
}
void loop()
{
if (Serial.available()>0){
String xString = Serial.readStringUntil(',');
String yString = Serial.readStringUntil(';');
x = xString.toInt();
y = yString.toInt();
Serial.print("X: ");
PRINT(x);
Serial.print("Y: ");
PRINT(y);
}
}
When I write the values, it works fine and prints back the values, but then it prints 0. I don't know why does that happen or how to fix it, so i would really appreciate if you could help me, because I need to finish this code as soon as possible.