Hi, a week ago my app had no problems receiveing values from arduino, which is these values = -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5 (not in a list) and when i send the value it only show "N0" nothing else, should print F1,F2,F3,F4,F5 and R-1,R-2,R-3,R-4,R-5 aswell.
What i see there is no problem in arduino.
Maybe last week there was incoming data, and now there isnt. What is the initial value of receive_data? The problem is that is empty field. You should move the last if block into the previous, fter the set global receive_data block so the second comparison only run if there is data arrived.
ye, so the inital value is set at 0 in decimal form, not text form, and i've tried putting the last if block under global_receive, but then i don't get a "N0" ...
Some remarks:
Your timer interval is too short. It should be shorter that the delay interval of sending messages in your Arduino. It should have a chance to send complete messages.
Then, it would be much easier if you would use a message delimiter. End every message from your Arduino with a println(). In the design section of App Inventor, set the delimiter for the BT component to 10. Then, set the number of bytes to receive to -1. App Inventor will now read always complete messages, instead of the number of bytes that are present at the clock timer event, which may be more than one or partial messages. See also here: http://ai2.appinventor.mit.edu/reference/components/connectivity.html#BluetoothClient
For debugging purposes, it is handy to have a label on your phone screen that shows your incoming data. While you are debugging you can see what is going on. when finished, make it invisible or delete it.
thanks for answer, i think i did everything that u said but doesn't work, delimeter to 10, timer interval set to 2, but what do u mean by setting number of bytes to receive to -1? where and how do i do that?
To help you properly Jimmy, we can't have upmpteen people guessing what you may or may not have done. We need to see your Arduino Sketch and all of your App blocks (of the screen concerned with Bluetooth). What is the Make/Model and Bluetooth version of your Bluetooth Module?
Note that for this type of project, "Timer Always Fires" should be False.
You made the timer interval even shorter???
Set it to 100 or similar. What is the delay in your .ino code? Can you post the part of your .ino code that sends the messages?
But this only works if you end every Arduino message with println();
The bytes available test must be > 0 (if zero, no bytes!)
In the BT Receive Block, numberOfBytes = -1
Is this App just for your own use? If so and it works fine, no problem but if others are to use it, their phones may or may not be as fast as yours (various reasons), in which case you need to allow a bit of time for all BT devices to be found before populating the ListPicker. You would also want to remind them to:
a) Switch the target device on
b) Switch Location on (phone)
c) Switch Bluetooth on (phone)