I have tried >1 or >2 but it still doesn't works
I checked the description for that block.
It attempts to receive text from the Bluetooth, and if it returns empty text, it is probably an error (in your code).
So there is problem in my Arduino code?
Maybe. That's all I know - I think a power user should know more than me.
ok thank you so much
From your Arduino code, I see you are sending NL-delimited messages of the form
single letter - space - number - NL
To receive complete messages, follow this standard advice:
Please see the Delimiter article in FAQ
Be sure to use println() at the end of each message to send from the sending device, to signal end of message. Do not rely on timing for this, which is unreliable.
In the AI2 Designer, set the Delimiter attribute of the BlueTooth Client component to 10 to recognize the End of Line character.
Also, return data is not immediately available after sending a request,
you have to start a Clock Timer repeating and watch for its arrival in the Clock Timer event. The repeat rate of the Clock Timer should be faster than the transmission rate in the sending device, to not flood the AI2 buffers.
In your Clock Timer, you should check
Is the BlueTooth Client still Connected?
Is Bytes Available > 0?
IF Bytes Available > 0 THEN
set message var to BT.ReceiveText(-1)
This takes advantage of a special case in the ReceiveText block:
ReceiveText(numberOfBytes)
Receive text from the connected Bluetooth device. If numberOfBytes is less than 0, read until a delimiter byte value is received.
If you are sending multiple data values per message separated by | or comma, have your message split into a local or global variable for inspection before trying to select list items from it. Test if (length of list(split list result) >= expected list length) before doing any select list item operations, to avoid taking a long walk on a short pier. This bulletproofing is necessary in case your sending device sneaks in some commentary messages with the data values.
May I know how can I check this? any programming or need to check manually
Also how to test for this?
Are you referring to the Arduino code for this?
Here is an updated blocks sample illustrating these ideas ...
Yes. But I already saw that in your (?) Arduino code.
But I need to use ListPicker... If I use these blocks then I need to change my code in Arduino right? Or these blocks are just add-on?
BlueTooth_delimiter_sample.aia (3.4 KB)
How can I open this file? which app do i need to use to open this?
Import it in app inventor
Download the file, on the top bar, click on Projects > Import project (aia) from my computer, and then upload the AIA file.
Thanks guys... imported
So i use this code to test my project right?
Yes indeed, this AIA is for testing
ok let me try... I'm new to this actually
But what should happen or what should i get in the app.... Looks like I get nothing
The output isn't working?