Shop OBEX P1 Docs P2 Docs Learn Events
help with code for bush button — Parallax Forums

help with code for bush button

studiomagicstudiomagic Posts: 10
edited 2007-12-06 21:40 in BASIC Stamp
I want to be able to push a NO button on P3·to move a servo. ·Here is what I have so far. It want let me move the servo more than once. I want to move each time the button is pushed. What am I missing?

DO

IF IN3 = 1 THEN
GOTO Blink:
ENDIF

LOOP

Blink:
DEBUG "Counterclockwise 10 o'clock", CR
FOR Counter = 1 TO 35
PULSOUT 13 1000
PAUSE 7
NEXT

DEBUG "Clockwise·3 o'clock", CR
FOR Counter = 1 TO 35
PULSOUT 13 1000
PAUSE 7
NEXT

DEBUG "Counterclockwise 10 o'clock", CR
FOR Counter = 1 TO 35
PULSOUT 13 1000
PAUSE 7
NEXT


·

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-12-06 04:43
    1) Blink needs to be a subroutine with a RETURN at the end. Change "GOTO Blink:" to "GOSUB Blink" (the ":" is only for the definition of the label).

    2) Blink will get called as long as the button is held down. If that's what you want, leave it as described.

    3) If you want only one set of movements, you have to wait after the DO for the button to be released like:
    DO
    LOOP UNTIL IN3 = 0
    
  • studiomagicstudiomagic Posts: 10
    edited 2007-12-06 05:07
    Hi Mike,

    Here's what I'm trying to do. I have two servo's, one is connected to P13 and the other is connected to P14.They will be moving eyes in a puppet. P2 is a push button for the left eye and P3 is a push button for the right eye. I don't want to have to hold down the button. I have programmed servo's to run a set per program so that both eyes blink together, but I want to interrupt the program and be able to blink each eyes individually. As it stands I can blink each eye only one time then the program starts back over and I have to wait until it get to "DO". I'm lost!!!!!
  • FranklinFranklin Posts: 4,747
    edited 2007-12-06 21:40
    Have you done as Mike suggested in his post? Try it and let us know what you get.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
Sign In or Register to comment.