Sending multiple data to arduino

hi ! I need your help :cry:

How can I send multiple data to arduono via bluetooth??

i know how to send a data to arduino via bluetooth like this,

if(BTSerial.available()) {
char data = BTSerial.read();

but i want to send multiple data and keep data to different variable like

if i click button a,b,c => send to arduino 30,60,90 > int range =
if i click button 1,2,3 => send to arduino 10,20,30> int spd =

And it is my code and app blocks

now i'm trying to get 3 different int variables range/spd/OF(onoff) by getting string type and using 'readStringUntil' function to identify each data

But it's result
(press button a- button 1- button move)

start
90
0
0

10
0
0

1
0
0


i want

start
90
10
1

please let me know ~~!~!~!~!

Hi @hwanghc123 ,
the first thing that I see is that you send capital letters (i.e. "A" , "S",...)
while you are expecting lowercase letters (i.e. "a", "s", ...). The receiver (Arduino code) will never match the case.
Second (multiple doubts) the HC06 baudrate is surely 9600 ? to which pins is attached ? Which Arduino board are you using ? The AI2 code that you posted does not show the initialization of the BT (on phone side).....
As you can see, there are many things that have to be verified before you expect it's working.
My suggestion is to have a look :nerd_face: on the tutorials that @Juan_Antonio or @Nilton_Santos have prepared and are available on the community: just type "Arduino tutorials" or "bluetooth HC06" in the search cell. I believe you will find the solution therein.
The link below is just an example of what you can find on your own.
(Bluetooth HC-06. Arduino. Send. Receive. Send text file. Multitouch. Image)

Best wishes. :+1:

First, thank you for your great comment !!

I understand what you said that difference of Capital and lowercase. I knew that but in this picture, they were mistyped :sweat_smile:

You can't see, of course( I didn't posted :flushed:), these uno board, BT module and pin attaches are no problem !
Actually, these are codes for controlling a servo motor and they are work well.

I think problem is seperate 3 datas to each variable and it's on programing skills..

I'll find some useful suggestion at that link that you recommended! :+1: :+1:

If you come up with a good idea, let me know !

have a nice day :smiley:

Hi @hwanghc123 ,
Ok I got it. Then my other suggestion is that when you try to convert a string into an integer, since the string contains both numbers and letters (i.e."90A"), the .toint() function can be foolished by this fact and most probably will respond with a 0 ? (honestly it should stop the conversion as soon as it finds a non integer number, but I don't know what happens if it encounters a character, I don't have an arduino available to run a test).
Take a look to the www.arduino.cc site and look for the .toint() explanation.
Sorry but I need to go to the office now and I can't continue. I believe you can find very useful hints in the tutorials I've suggested before. Also there are samples of servo motors drivers by using MIT AI2 on the community. A serach on that will help you as well.
Cheers.

Cheers.

1 Like

thank you very much for mentioning my tutorials

1 Like