Shop OBEX P1 Docs P2 Docs Learn Events
push button programming question on BS2 — Parallax Forums

push button programming question on BS2

MplsBobMplsBob Posts: 3
edited 2008-04-27 16:11 in BASIC Stamp
Hi,
I'm new to this. I went through the What's... book and went through the help index in the software. I can't seem to figure this out.
I want to push the button on the homework board and after I let go I want a pause for a few seconds, then turn on the continuous servo for few seconds then stop.
Here is the code, but it doesn't work. Is there any place I can look for sample programs?
Thanks, Bob

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


duration VAR Word

duration = 650

DO
begin:
IF IN3 = 1 THEN
PAUSE UNTIL IN3=0
ENDIF
IF IN3 = 0
THEN PULSOUT 14, duration
PAUSE 10
ENDIF


LOOP

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-04-27 13:16
    First of all, "It doesn't work" is not helpful. A description of what happens is much better. Second, there are lots of examples in the various tutorials, just maybe not exactly what you want or need. Do make sure you have the Parallax Basic Stamp Manual. That explains and gives examples of each of the operators and statements of Stamp Basic. You can download it ... Go to the main Parallax web page, pick the Resources tab, then Downloads, then BASIC Stamp Documentation and you'll see "BASIC Stamp Syntax and Reference Manual". The Nuts and Volts columns are also good resources. You'll see the link off the Resources page.

    You've got the right idea. Partly, you didn't make your program do what you said it should do:
    1) Wait for the pushbutton to be pressed (look at the DO / LOOP / UNTIL statement)
    2) Wait for the pushbutton to be released (another DO / LOOP)
    3) Turn on the servo for a few seconds. This involves sending out a pulse every 20ms (better than 10ms). Look at the FOR / NEXT statement.
    4) Stop

    Build your program a step at a time and insert DEBUG statements to follow its progress. Make sure it compiles at each step.
  • MplsBobMplsBob Posts: 3
    edited 2008-04-27 16:11
    Thanks Mike, I'll check out the Nuts and Volts and the Reference manual. I learn by seeing examples of programs and I wasn't sure if I can make it work by programming alone or if I needed to add something to the breadboard like a capacitor. I'll keep plugging away.
    Bob
Sign In or Register to comment.