Can you put a time window for an input?
correao69
Posts: 2
I have Bush button one (PB1), after that is pushed, i want to set a 6 second window for the second bush button(PB2) to be pressed. If PB2 is clicked with in the 6 seconds, it sets off leds and a buzzer, if it is pressed after the six seconds, nothing happens, and it just loops back to looking for PB 1to be pushed.· How should i do this?
Post Edited (correao69) : 11/9/2006 4:14:08 PM GMT
Post Edited (correao69) : 11/9/2006 4:14:08 PM GMT
Comments
Lee
·
·· One thing you can do to put a timeout on the input of something is to put a counter in the loop checking the input.· Each pass through the loop increment the counter and check for the upper limit.· When reached you brand out of that loop.· I do this myself, although depending on what is happening in the loop you sometimes have to experiment with the values.· The only other way would be to use an external RTC such as the DS1302 for timing.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
Main:
IF PushButton1 = (1 or 0 depending on how you wire it) THEN GOSUB CheckForPB2
' Other code goes here
GOTO Main
CheckForPB2:
FOR x = 1 to 120 ' 120 iterations of PAUSE 50 = 6 seconds, - of course actual process time of code.
IF PushButton2 = (1 or 0 depending on how you wire it) THEN Action
PAUSE 50
NEXT
GOTO Main
Action:
Light the lights
Sound the sounds
Ding the Dingers
GOTO Main
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
(Frequently heard from other's)
Tommy, I know it wasn't designed to·x, but can you make it·do x·anyway?
·
know the difference. Set up the polarity in accordance with the active low/high state of PB2,
and pushing your button will look like a start bit. See manual for details.
DH
using 3 pins PushButton1, PushButton2 and a third pin for an R/C timer.
Logic would be
wait for pin1
charge capacitor with pin3
change pin3 back to input
wait for pin2 to be pressed, timeout if pin3 goes low
if pressed check if pin3 still high
if pin3 still high it is within 6 second window
A capacitor and resistor that will hold pin3 high for 6 seconds would be attached to pin3
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Think outside the BOX!