So everything is working OK then?
Your scale is effectively 0 - 254 and 256 to 510. Isn't the middle position of the Ball (255) difficult to achieve?
So everything is working OK then?
Your scale is effectively 0 - 254 and 256 to 510. Isn't the middle position of the Ball (255) difficult to achieve?
No, the ball is brought to the center ok; however, again the one value list method doesn't work for values higher than 255. How can I send values higher than 255 over bluetooth to my arduino.
Very strange.
You could send text values and convert to ints in the Sketch with atoi().
Tried that, I tried sending 255 as a text value using Bluetooth.SendText, it outputted 50, 53, 53
....using the Send Text Block. It should be foolproof, so many App Inventor Users. What does the Sketch/Script look like?
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.