• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

need help quick!!!! basic stamp......

Status
Not open for further replies.

jhill44

New Member
here is a copy of the program i am running........ i have constructed a bot that i am hoping to run autonomously. this is basically an automated refrigerator with obstacle avoidance. with the basic program that i am running right now a universal remote initiates the movement of the bot and it then runs through the obs. avoidance. as it runs through the obs. avoidance i would like to beable to stop the bot by pressing another button, but with the way i have it written it wont exit out of the loop command....... i have tried many different things to try and execute this simple stop command but nothing seems to work.. any suggestions


' {$STAMP BS2}
' {$PBASIC 2.5}

DEBUG "program running"

'------------[variables]-----------------------------------------------

irdetectleft VAR BIT
irdetectright VAR BIT
irdetectcenter VAR BIT
BUTTON_CODE VAR BYTE 'Infrated Button Code
DEVICE_CODE VAR BYTE 'Infrared Device Code
'------------[main routine]--------------------------------------------
'***************************
'* MAIN PROGRAM *
'***************************

MAIN:
GOSUB COMMAND_030 'Send the Remote control Command to Infrated Control Freak

GOTO MAIN

COMMAND_030:
SEROUT 14, 16468, [30]
poop:
SERIN 15, 16468,1000,main, [device_code, button_code]
DEBUG "button code =", DEC Button_Code," Device Code =",DEC Device_code," ", CR
DEBUG " ",CR
DEBUG "____________________________",CR
DEBUG HOME
IF Button_code = 21 AND Device_code = 1 THEN obstacle_avoidance
IF BUTTON_code = 101 AND device_code = 1 THEN STOP_bot
GOTO poop



'----------[subroutines]----------------------------------------------



obstacle_avoidance:
DO
FREQOUT 8, 1, 38500
irdetectleft = IN9

FREQOUT 2,1, 38500
irdetectright = IN0

FREQOUT 3,1, 38500
irdetectcenter = IN4

IF (irdetectcenter = 0) THEN
GOSUB back_up
ELSEIF (irdetectleft = 0) THEN
GOSUB turn_right
ELSEIF (irdetectright = 0) THEN
GOSUB turn_left
ELSE
GOSUB forward_pulse
ENDIF
LOOP

forward_pulse:
PAUSE 100
SEROUT 16, 8276, ["!A1E", CR]
SEROUT 16, 8276, ["!b1E", CR]
RETURN

turn_left:
PAUSE 20
SEROUT 16, 8276, ["!A14", CR]
SEROUT 16, 8276, ["!b14", CR]
RETURN

turn_right:
PAUSE 20
SEROUT 16, 8276, ["!A1E", CR]
SEROUT 16, 8276, ["!b1E", CR]
RETURN

back_up:
PAUSE 20
SEROUT 16, 8276, ["!a1E", CR]
SEROUT 16, 8276, ["!B1E", CR]
RETURN

STOP_bot:
PAUSE 20
SEROUT 16, 8276, ["!A00", CR]
SEROUT 16, 8276, ["!B00", CR]
 
Status
Not open for further replies.

EE World Online Articles

Loading
Top