Posted: 12:17am 12 Apr 2015 |
Copy link to clipboard |
 Print this post |
|
Hi all,
Have spent several days playing (fighting ) with a JY-MCU serial to bluetooth module so I can send data from a Colour Maximite to an Android tablet.
The module, shown below, is a JY-MCU unit. It has a bluetooth device name of linvor, connects at 9600, 8, N,1
On the CMM, I used the following code
open "com1:" as #2
do
print "Text to be sent to the tablet",#2
pause 2000
loop
On the tablet the following code will connect to the JY-MCU then loop waiting for data from the CMM
The code for the Android tablet is written in drBasic - this is free and available from http://laughton.com/basic/
!!
Routine to Get message String from external Bluetooth source
Code written in drBasic For Android tablet
Returns With String in csmsg$ And ndflag Set
!!
ndflag = 0 % new data
! BT Open will request bluetooth device - Select linvor
BT.OPEN
BT.CONNECT
DO
BT.STATUS s
UNTIL s = 3
! status 3 means connected
Do
BT.STATUS s
UNTIL s = 3
BT.STATUS S
!!
This first Do loop will keep repeating until returned status is Not 3
ie. the bluetooth link is down
!!
Do
Do
BT.READ.READY rr1
until rr1 <> 0
pause 100 % needed to allow bluetooth message to stabilise
Do
rmsg$ = ""
csmsg$ = ""
BT.READ.READY rr
while rr <> 0
BT.READ.READY rr
BT.READ.BYTES rmsg$
csmsg$ = csmsg$ + rmsg$
repeat
UNTIL rr = 0
ndflag = 1
!!
csmsg$ contains the String of characters sent in by bluetooth
- remove this when you actually use the code
!!
Print csmsg$
BT.STATUS S
!!
This is the End of the Do loop that tests status
!!
Until S <> 3
Any questions, feel free to PM me or ask on the forum.
Cheers,
Doug.
Edited by panky 2015-04-13 ... almost all of the Maximites, the MicromMites, the MM Extremes, the ArmMites, the PicoMite and loving it! |