I have a ball on a canvas that I can drag around from y = 0 to y = 540. I want to send these number to my arduino via HC05 module, then map it to a PWM (0-255) signal. Since 540 won't fit in one byte, I sent it to my arduino by means of 2 bytes. However this resulted in the arduino serial splitting the two bytes as (00001110) 14 and (000000001) 1. Is there anyway I can send or receive the whole number (540 (00000000100001110)).
Another question - how are you mapping a range of 0 - 540 to a range of 0 - 255? Wouldn't it be easier if the canvas range was 0 - 510 (or even 0 - 255) ?
I don't have an Arduino to hand for testing, but try this snippet:
It works, but my project involves a ball on a canvas. I modified your code to work with the ball and canvas, but how would I send a value larger than 1 byte using the Send a list of bytes method?
I would look for a Send a list of Integers method.
Integers are longer than bytes, although that name is highly presumptuous, presuming to be able to hold an infinite number of bits or intentionally vague, not giving you any hint as to actual size in bits (at least 16?)
I used the ball and canvas method because I wanted to style the app to look more personalized, that is the only reason, and yes I'm only getting the values of the Y direction.
Yes, I intend to use the 0-510 range for direction and speed control in my Arduino code. I'm going to subtract 255 from the input from my app; the middle value of the range 0-510 would be 255 and that would be converted to 0 because I want the PWM output to be 0 when the ball is in the center...
Here's my app inventor code and screen:
Did this fail? I see you have incorporated it into your custom code. I don't quit get your description - do you mean the App will also send negative integers (0 to -255)?