×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

HELP basic stamp!!!!

HELP basic stamp!!!!

HELP basic stamp!!!!

(OP)
working on an autonomous refrigerator and im running into a wall!!! seems to be running a continuous loop and im not to sure how to get out of it. i am trying to initiate the autonomous movement with a universal remote, then it runs through a series of obstacle avoidance subroutines..... i placed an if....then statement at the beginning of the program which states if button_code and device_code are pressed (my designated stop button) then so to sub stop_bot.  although i feel like this should work it doesn't. ive tried a do.....loop until command and that doesnt seem to be doing the trick either. any help would be great for i am on a deadline to finish this project relatively soon. here is a copy of the code i have written............


' {$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]

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login



News


Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close