bluetooth and basic on a pc
Sticky
Posts: 42
Anybody had any experience interfacing an easy bluetooth module with a basic program on a PC and would you like to give some pointers if you have? I'm trying out something called just Basic and I seem to connect to the port for the bluetooth but I can't get data from it yet. Here is the program I'm trying.
txt
734B
Comments
Ill give you a generic line of code i use.
' {$STAMP BS2}
' {$PBASIC 2.5}
mresult VAR Byte
BT_RX PIN 2 ' RX of the Easy Bluetooth
BT_TX PIN 0 ' TX of the Easy Bluetooth
LED PIN 8 ' Indicator LED for Bluetooth Connection
j VAR Nib
DO
FOR j = 1 TO 3
HIGH led
PAUSE 100
LOW led
PAUSE 100
NEXT
'DEBUG "Waiting for data . . ." , CR
SERIN BT_RX , 84 , 2000, no_data , [noparse][[/noparse]mresult]
DEBUG "Bluetooth got data - woo woo ", CR
SEROUT BT_TX , 84 ,[noparse][[/noparse]"The bluetooth, just got data" , CR]
PAUSE 250
LOW led
PAUSE 250
_pass:
PAUSE 2000
SEROUT BT_TX , 84 ,[noparse][[/noparse]"The bluetooth, just transmitted this" , CR]
PAUSE 500
LOOP
no_data:
DEBUG "No data ", CR
PAUSE 1000
GOTO _pass
In the BASIC stamp editor enter this:
If you dont have Visual Studio 2008 you can download it from Microsoft. Get Visual Basic Express.
Open the attached zip and open the .sln (solution) file.
It will show you the Form window. Click on the SerialPort1 on the bottom of the screen, and it will show properties window on the right for it.
Scroll down and find COM3, change this to yours (unless thats what you have.)
Now press F5 or click run on the menu bar. Click connect, if it gives you error, then you have the wrong COM port selected. Otherwise it should display 50 in the form.
Hope this helps.