
Copyright © Parallax Inc. Easy Bluetooth (#30085) v1.3 4/14/2010 Page 8 of 9
' -----[ I/O Definitions ]-------------------------------------------------
BT_RX PIN 2 ' RX of the Easy Bluetooth
BT_TX PIN 0 ' TX of the Easy Bluetooth
LED PIN 5 ' Indicator LED for Bluetooth Connection
' -----[ Constants ]-------------------------------------------------------
BT_SPEED CON 84 ' baud 9600 true UART
' -----[ Variables ]-------------------------------------------------------
tLeft VAR Word ' Left Servo control pulse durations
tRight VAR Word ' Right Servo control pulse durations
temp VAR Word ' Temp variable
' Buffer array not declared as buffer VAR Word(5) for SERIN functionality.
' It can still be accessed as buffer(0), buffer(1), etc. However,
' buffer0, buffer1, etc. should be used in SERIN commands with variations
' of WAIT.
buffer0 VAR Byte ' Buffer - Start char = $ff
buffer1 VAR Byte ' Message Index value
buffer2 VAR Byte ' Command
buffer3 VAR Byte ' Argument 1 (return data 1)
buffer4 VAR Byte ' Argument 2 (return data 2)
buffer VAR buffer0 ' For standard array indexing
msgIndex VAR Byte ' message index
rxc VAR Byte ' Receive Clear
' -----[ Initialization ]--------------------------------------------------
Program_Start:
LOW LED
DEBUG CLS
PAUSE 1000 ' Wait for the RBT-001 radio to be ready.
msgIndex = 0
buffer0 = $FF ' Connection packet
buffer1 = msgIndex
buffer2 = $CC
buffer3 = 100
buffer4 = 100
GOSUB Set_Servo_Speed
DEBUG CR,"Waiting connection..." ' wait for connection request
SERIN BT_RX, BT_SPEED, [WAITSTR buffer \ 3, buffer3, buffer4]
' -----[ Program Code ]----------------------------------------------------
DO
SELECT buffer2
CASE $CC ' Connect
HIGH LED
msgIndex = 0
DEBUG CR,"Connected"
GOSUB Reply