Buffered trigger
I want to make a buffered trigger.
Can I use the attached circuit, and test if switch is pressed with:
myvar VAR Byte
LOW 0
Loop:
RCTIME 0, 1, myvar
IF myvar > (somevalue) THEN
DEBUG "Triggered!"
LOW 0
ENDIF
GOTO Loop
Can I use the attached circuit, and test if switch is pressed with:
myvar VAR Byte
LOW 0
Loop:
RCTIME 0, 1, myvar
IF myvar > (somevalue) THEN
DEBUG "Triggered!"
LOW 0
ENDIF
GOTO Loop
Comments
First of all, include a 220 Ohm (or larger) resistor between the I/O pin and the rest of your circuit
How you program things depends on how you want things to behave. I assume that you want this circuit to "remember" that the switch had be closed until you reset the circuit.
To reset the circuit ... either at the start of your program or some time after you've checked the switch setting, do: LOW 0
To check whether the switch has been pressed, you only have to do: IF IN0 THEN GOTO switchPressed
The I/O pin input circuitry already uses the voltage on the input pin to decide whether the pin is a logic 0 or logic 1. Usually that threshold is about 1/2 of the supply voltage.