Shop OBEX P1 Docs P2 Docs Learn Events
bluetooth terminal boebot help — Parallax Forums

bluetooth terminal boebot help

walkin79walkin79 Posts: 29
edited 2012-08-09 19:27 in BASIC Stamp
this is my code, everything is working fine, but i would like to have the servos move without the jitter of interupted signal. the pulse out is constantly repeated, how can i have the pulse out continue until i stop it. i know i will have to write a stop code but what would the code look like to the servo?








TerminalBoeBotControl_Keypad.bs2
' Moves the Boe-Bot based on the numbers 2, 4, 6, 8 or the
' letters A, W, D, X.
'control + d opens the debug window ( you must connect bluetooth and get the
' correct com port example com 5 look in stamps in class mini projects boe bot
' bluetooth
' {$STAMP BS2}
' {$PBASIC 2.5}
Piezo PIN 4
RX PIN 2 ' RX of the Easy Bluetooth
TX PIN 0 ' TX of the Easy Bluetooth
ltServo PIN 13 ' Left Servo Pin
rtServo PIN 12 ' Right Servo Pin
FwdLtFast CON 850 ' Left servo forward full speed
BwdLtFast CON 50 ' Left servo backward full speed
FwdRtFast CON 50 ' Right servo forward full speed
BwdRtFast CON 850 ' Right servo backward full speed

Baud CON 84 ' Baud set at 9600
myByte VAR Byte ' Byte to establish connection
index VAR Word ' READ index/character storage
character VAR Word
note1 VAR Word ' for peizo noise
x VAR Word ' for peizo noise
dirChar VAR Word ' Stores directional character
counter VAR Word ' Counter for FOR...NEXT loop




DO
' Recieve character from the PC
SERIN RX, Baud, [dirChar]
IF (dirChar = "8") OR (dirChar = "w") THEN
GOSUB Forward
ELSEIF (dirChar = "2") OR (dirChar = "x") THEN
GOSUB Backward
ELSEIF (dirChar = "4") OR (dirChar = "a") THEN
GOSUB Left
ELSEIF (dirChar = "6") OR (dirChar = "d") THEN
GOSUB Right
ELSEIF (dirChar = "5") OR (dirChar = "p") THEN
GOSUB noise
ENDIF
LOOP
Forward:
SEROUT TX, BAUD, [CRSRXY, 7, 0, "*", CRSRXY, 6, 1, "*", CRSRXY, 8, 1, "*"]
PULSOUT ltServo, FwdLtFast
PULSOUT rtServo, FwdRtFast
PAUSE 20
SEROUT TX, BAUD, [CRSRXY, 7, 0, " ", CRSRXY, 6, 1, " ", CRSRXY, 8, 1, " "]
RETURN
Backward:
SEROUT TX, BAUD, [CRSRXY, 7, 6, "*", CRSRXY, 6, 5, "*", CRSRXY, 8, 5, "*"]
PULSOUT ltServo, BwdLtFast
PULSOUT rtServo, BwdRtFast
PAUSE 20
SEROUT TX, BAUD, [CRSRXY, 7, 6, " ", CRSRXY, 6, 5, " ", CRSRXY, 8, 5, " "]
RETURN
Left:
SEROUT TX, BAUD, [CRSRXY, 3, 3, "*", CRSRXY, 4, 2, "*", CRSRXY, 4, 4, "*"]
PULSOUT ltServo, BwdLtFast
PULSOUT rtServo, FwdRtFast
PAUSE 20
SEROUT TX, BAUD, [CRSRXY, 3, 3, " ", CRSRXY, 4, 2, " ", CRSRXY, 4, 4, " "]
RETURN
Right:
SEROUT TX, BAUD, [CRSRXY, 11, 3, "*", CRSRXY, 10, 2, "*", CRSRXY, 10, 4, "*"]
PULSOUT rtServo, BwdRtFast
PULSOUT ltServo, FwdLtFast
PAUSE 20
SEROUT TX, BAUD, [CRSRXY, 11, 3, "*", CRSRXY, 10, 2, "*", CRSRXY, 10, 4, "*"]
RETURN

noise:
FOR x = 1 TO 50 ' run about 5 seconds
RANDOM note1 ' create random note
note1 = note1 // 2000 ' don't let note go to high
FREQOUT 4,50,note1 ' play it
PAUSE 100 ' short pause between notes
NEXT
RETURN

Comments

Sign In or Register to comment.