Does "do it" verify the correct string being sent?
Ah, Use the Text Join block to postfix \n
Nope, I'm getting outputs 47 48 110 now
And the DoIt Results?
I see you are compensating for the Ball diameter? You can set the coordinate output to Ball Center.
You want to send 510. This number will be sent in 2 bytes. You will get 1 (00000001) and 254 (11111110). To convert it back to a decimal number, first byte "1" multiply by 256 and then add the second byte "254".
1x256 + 254 = 510
dolt results?
You can also send the number as text. Then you get 53 49 48. To convert this to a number you have to subtract 48 from each byte.
53-48 = "5", 49-48 = "1", 48-48 = "0".
These are simple methods.
While running the App via the Companion, you can right-click on any block that holds values and select Do It to see the current value.
Those are of course the ASCII character numbers for 510.
Can you use this
https://www.arduino.cc/reference/en/language/functions/communication/serial/parseint/
instead of Serial.read()?
Serial.parseInt()
Parsing stops when no characters have been read for a configurable time-out value, or a non-digit is read;
Certainly sounds promising.
so what exactly does this do?
Ya, that solved it! Thank you so much! Although I'm kinda confused on what exactly Serial.parseInt(); does, hope you can help me with that.
So the value will be read until the function hits a no-digit - in your case, \n
Another possibility to receive texts or numbers.
char end_char = '\n';
String texto;
void setup() {
Serial.begin(9600);
}
void loop() {
if(Serial.available()) {
texto = Serial.readStringUntil(end_char);
Serial.println(texto);
}
}
So just to clarify, the app sends my inputs as ASCII values to my serial in my arduino program. Then the Serial.parseInt() function converts it back to their integers until it reaches '/n' which signals the end of that integer?
That is our expectation, given the Arduino description of the function. The proof of that pudding is in the eating and it is working for you now?
Right, it works now. Thank you so much.
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.