Posted: Wed Jun 17, 2015 12:50 pm Post subject: Joystick bluetooth Commander
Hi
I try to use an Android app to run a robot "Joystick bluetooth Commander"
but do not know how I should decoda input data flow.Android app
sends ASCII characters'
The data frame is send via BlueTooth to the arduino board and decoded.
'2' is Ascii 32 hex (decimal 50)
'0' is Ascii 30 hex (decimal 4
Data frame: <0x02 0x32 0x30 0x30 0x32 0x30 0x30 0x03>
Data is sent as ascii shall I handle it as a close and use the ASC ()
Posted: Wed Jun 17, 2015 12:52 pm Post subject: Jag försöker igen utan smilys
Hi
I try to use an Android app to run a robot "Joystick bluetooth Commander"
but do not know how I should decoda input data flow.Android app
sends ASCII characters'
The data frame is send via BlueTooth to the arduino board and decoded.
'2' is Ascii 32 hex (decimal 50)
'0' is Ascii 30 hex (decimal 48)
Data frame: <0x02 0x32 0x30 0x30 0x32 0x30 0x30 0x03>
Data is sent as ascii shall I handle it as a close and use the ASC ()
there are multiple ways to do it. you get : 02 31 36 38 31 39 32 03 02 31 36 38 31 39 32 03
which means 02 is the start of the frame and this is what you need to watch for.
the 03 seems to mark the end of a frame. I think you also get CR + LF ?
That would make it simple. Just use INPUT and store the data into a line. Then extract the data using mid()
Code:
dim s asstring*50, dgt2 asString*2
s="02 31 36 38 31 39 32 03 02 31 36 38 31 39 32 03" dim dgt asstring*3,j asByte,b asByte
for j=4to10step3'get 32 36 38
dgt2=mid(s,J,2)'get 2 digits
b=hexval(dgt2)-48
dgt=dgt +str(b) next dim value1 asInteger
value1=val(dgt)
you can also check out split() _________________ Mark
Posted: Wed Jun 17, 2015 1:53 pm Post subject: Android
Thanks for the reply Mark, I have tried to use the hex (), Val (), Chr () and it has not been good. It says in the text that should (data [X] -4 * 100 -48 is well because it is ASCII can not load byte for byte and decod directly? No, now I will test your proposal many thanks Maxneo
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum