Eb550 & PIR program problems
HI,
I am working on a Robot that will use the eb500 chip to move the BOE-BOT around and then to trigger the PIR sensor.
So far as of now I have gotten everything to work except I can't figure out a command that will cancel the loop for the PIR sensor and rerun the MAIN program. What I have now is listed below if you have any ideas it would really help.
' {$STAMP BS2}
' {$PBASIC 2.5}
LOW 12
LOW 13
PIR PIN 13 '
Pizo PIN 2 '
counter VAR Byte
LMotor CON 12
RMotor CON 13
CmdData VAR Byte
Main:
SERIN 0,84,[noparse][[/noparse]DEC1 CmdData]
DEBUG DEC1 CmdData
BRANCH CmdData,[noparse][[/noparse]runreset, fastleft, go, fastright, hold, back, gomain]
GOTO Main
DEBUG "connecting",CR
Connect:
PAUSE 1000
SEROUT 1,84,[noparse][[/noparse]"con 00:0C:84:00:42:E9",CR]
DEBUG "connected, attempt commands",CR
runreset:
DEBUG CLS
FOR counter = 40 TO 0
DEBUG HOME, "WARMING UP:", DEC2 counter
PAUSE 1000
NEXT
counter = 0
DEBUG HOME, "WAITING... "
DO
IF PIR = 1 THEN
DEBUG HOME, "Hello.."
OUTPUT 2
FREQOUT 2, 600, 3800
FREQOUT 2, 600, 3650
ENDIF
IF PIR = 0 THEN
DEBUG HOME, "Nothing"
ENDIF
LOOP
gomain:
END
GOTO Main
back:
PULSOUT LMotor,500
PULSOUT RMotor,1000
SEROUT 1,84,[noparse][[/noparse]"up-"]
GOTO Main
fastleft:
PULSOUT LMotor,650
PULSOUT RMotor,650
SEROUT 1,84,[noparse][[/noparse]"left-"]
GOTO Main
go:
PULSOUT LMotor,1000
PULSOUT RMotor,500
SEROUT 1,84,[noparse][[/noparse]"back-"]
GOTO Main
fastright:
PULSOUT LMotor,850
PULSOUT RMotor,850
SEROUT 1,84,[noparse][[/noparse]"right-"]
GOTO Main
Hold:
SEROUT 1,84,[noparse][[/noparse]"hold position "]
GOTO Main
I am working on a Robot that will use the eb500 chip to move the BOE-BOT around and then to trigger the PIR sensor.
So far as of now I have gotten everything to work except I can't figure out a command that will cancel the loop for the PIR sensor and rerun the MAIN program. What I have now is listed below if you have any ideas it would really help.
' {$STAMP BS2}
' {$PBASIC 2.5}
LOW 12
LOW 13
PIR PIN 13 '
Pizo PIN 2 '
counter VAR Byte
LMotor CON 12
RMotor CON 13
CmdData VAR Byte
Main:
SERIN 0,84,[noparse][[/noparse]DEC1 CmdData]
DEBUG DEC1 CmdData
BRANCH CmdData,[noparse][[/noparse]runreset, fastleft, go, fastright, hold, back, gomain]
GOTO Main
DEBUG "connecting",CR
Connect:
PAUSE 1000
SEROUT 1,84,[noparse][[/noparse]"con 00:0C:84:00:42:E9",CR]
DEBUG "connected, attempt commands",CR
runreset:
DEBUG CLS
FOR counter = 40 TO 0
DEBUG HOME, "WARMING UP:", DEC2 counter
PAUSE 1000
NEXT
counter = 0
DEBUG HOME, "WAITING... "
DO
IF PIR = 1 THEN
DEBUG HOME, "Hello.."
OUTPUT 2
FREQOUT 2, 600, 3800
FREQOUT 2, 600, 3650
ENDIF
IF PIR = 0 THEN
DEBUG HOME, "Nothing"
ENDIF
LOOP
gomain:
END
GOTO Main
back:
PULSOUT LMotor,500
PULSOUT RMotor,1000
SEROUT 1,84,[noparse][[/noparse]"up-"]
GOTO Main
fastleft:
PULSOUT LMotor,650
PULSOUT RMotor,650
SEROUT 1,84,[noparse][[/noparse]"left-"]
GOTO Main
go:
PULSOUT LMotor,1000
PULSOUT RMotor,500
SEROUT 1,84,[noparse][[/noparse]"back-"]
GOTO Main
fastright:
PULSOUT LMotor,850
PULSOUT RMotor,850
SEROUT 1,84,[noparse][[/noparse]"right-"]
GOTO Main
Hold:
SEROUT 1,84,[noparse][[/noparse]"hold position "]
GOTO Main
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
DO WHILE PIR<1
LOOP
Jeff T.