Shop OBEX P1 Docs P2 Docs Learn Events
school project, help needed — Parallax Forums

school project, help needed

confused2confused2 Posts: 1
edited 2008-05-17 20:24 in Learn with BlocklyProp
we are doing a mini project in class where we have to pushh a button three times to make a light turn on for 15 second. i have the code setup to where i push the button once to have the led come on for 15 seconds. my question is what code do i have to put in so that the led wont come on until i push the button three times? this is what i have so far:

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

DO
counter VAR Word
IF IN3 = 1· THEN
HIGH 14
PAUSE 15000
LOW 14

ELSE
· PAUSE 10
ENDIF
LOOP

thanks

Comments

  • BeanBean Posts: 8,129
    edited 2008-04-18 17:16
    First of all, thank you for being honest and letting us know that this is a school project.

    You have a good start, but want you want to do is in your "IF IN3 = 1 THEN" section, make the code add 1 to the counter (instead of turning on the light).

    Then make another section that says "IF counter = 3 THEN" and put your code in there that turns on the light.

    I hope this is helpful, I don't want to give to much away.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Did you know that 111,111,111 multiplied by 111,111,111 equals 12345678987654321 ?

    www.iElectronicDesigns.com

    ·
  • P!-RoP!-Ro Posts: 1,189
    edited 2008-05-17 20:24
    one thing to be careful of: make sure there is a pause command after it is pushed. If there isn't, you could have it repeat 3 times before you let go of the button. Try making the pause from about half a second (500ms) to 1 second (1000ms) good luck!
Sign In or Register to comment.