Hello everyone!
I would reall appreciate if anyone could help me with the following problem (or maybe a bug?!)!
I made an app where you send text from Arduino via Bluetooth in App Inventor in order to play a certain voice message with player. The problem is that no matter the text(numbers) that I send, it only accepts the first statement (as shown in the pictures) and not the rest... even though everything seems to be working perfect with any number but only for the first statement...
I am sending text from Arduino with Serial.println("1") etc.
I can provide the full code of both Arduino and App Inventor if needed/asked in order to receive some help figuring out if there's any kind of bug or if there's something I'm doing wrong and can't get it to work properly for every statement I want to add...
Thank you all in advance and I could really use some of your help guys !
1 Like
I don't see anything wrong in your code here, looks all fine to me... could you please tell me what calls the clock?
There is a "DelimiterByte" property in the bluetooth component, set this property to 10. Then detach the "BytesAvalibleToReceive" blocks from the purple "ReceiveText" blocks and add "-1" numeric blocks instead.
Connect "-1" to soccet "numberOfBytes".
1 Like
Well, if there's nothing wrong in the code then why does only the first statement work and the second one doesn't?
The number "1" is being triggered/sent when an IR Sensor detects an obstacle and the number "2" has to do with RFID Cards being read by an RFID Sensor. When the numbers are sent from Arduino to App Inventor via Bluetooth it should trigger the app to play the correspodent sound messages (the media I use in the app)
Ok, so I hope now I got it right (after I ve seen the pic you ve uploaded). So, in my arduino app I shoud keep it as it is? Serial.println("1") or change it to Serial.println("-2") etc? (Sorry for asking silly questions but I m not much of a programmer at all
)
Serial.println("1"); and Serial.println("2");
1 Like
Awesome, let me try it real quick and I ll let you know how did it go. In the meantime thank you for your patience and help!
Wow, finally! It works! Thank you so much!!!! I really appreciate your help! Just one more question: By setting the delimiter to 10 does that mean that I can only add up to 10 statements at all or can I add up to as many as I want? (If so, whats the limit of how many statements I can add?)
There is no limit, you can add as many instructions as you like.
2 Likes
Oh, so I just add any instructions/statements I want and I dont have to change the delimiter from 10 (that already is). Again, thank you so much!
Right click on any bluetooth block and select help from the context menu. A page will open with a description of each block in the bluetooth component. After reading this, I think you will understand what DelimiterByte means and why I suggested using "-1" with the ReceiveText block.
2 Likes
Thanks, now I think I got to understand it a little bit better! You're the best!
@Patryk_F Good evening Patrick and sorry for disturbing. I did what you said about using a delimiter etc and my project worked! Although, there's a problem and I m not sure how and if there's a way to solve it. I m using an RFID Sensor and when I m scanning a certain RFID tag I want the arduino to send a number in app inventor via bluetooth in order for my mobile app to play a specific voice message. The problem is that with the delimiter, I have to swipe the RFID tag 1 time in order to fulfill the 1st statement, 2 times for the 2nd one and goes on. Also, it can't get 2 different values at the same time (meaning that for example when my IR sensor sends the number 1 and I m swiping an RFID tag that sends the number 2, its not possible for them to be sent at the same time but for example it will first send one of those numbers and then the other one). I can provide screenshots of both arduino and app inventor code if needed. Thank you very much in advance for any reply
You may want to capture the output that you get on the phone side of things. Something that seems to be missing from this thread is that the BluetoothClient component will read up to either N bytes when N > 0 or until it sees a byte with the delimiter value (10 in this case) when the number of bytes is -1. The byte value 10 corresponds to the ASCII newline, which you get by using the Serial.println(...) function (the value is written and then the newline character). If you're swiping two tags, it's likely sending the sequence "1\n2\n", or something to that effect. It might be easier to debug if you show the code running on the Arduino since it would give more insight into how you're processing the RFID tag.
2 Likes
Hmm I see... Here's the arduino code. I hope it helps! I m really stuck and I don't know how to fix this problem. Any help is really welcomed and appreciated!
Edit: the delay in the code is solely for making sure that the voice message will be played till the end before receiving another information and also in order to not keep playing the message so fast that the voice message won't be played at all or till the end of it.
@ewpatton Hey there, so...do you think there's an actual solution to my problem?
Best regards,
Thanos