I have created a motor-driven lock for a workshop door, and all is working well. The circuit is straightforward, utilising an 08M2 with:
However, I'd like to up the ante and introduce a code to unlock the door. The limitation is that I only want to use the single control button to enter the code. I have a very elementary key-code check in place, which requires a single press, then a release, then a press for between x and y seconds (e.g. between 2 and 5 seconds), which is quite straightforward...
I'd like to introduce something more elegant that would require something like (e.g.) two quick presses and two short presses in order to unlock, but I can't think of how to code it more elegantly than hard coding the required presses using repeated elements of the above example code.
Can anyone suggest some ideas for a more elegant solution?
On a related note, I tried using the COUNT command with which I had limited success due to debouncing problems. Could I solve the debouncing with something as simple as a capacitor across the key button (it's a simple NO push-button). If so, what value cap should I use?
Thanks in advance.
- two outputs to drive the motor through an L293D
- one input for two limit switches (in parallel) so the motor knows when to stop
- one output for a status LED
- one input for the single control button
However, I'd like to up the ante and introduce a code to unlock the door. The limitation is that I only want to use the single control button to enter the code. I have a very elementary key-code check in place, which requires a single press, then a release, then a press for between x and y seconds (e.g. between 2 and 5 seconds), which is quite straightforward...
Code:
enter_key:
gosub check_sw_key_release ;loops until key is released
pause 500
time = 0 ; reset timer
DO WHILE sw_key = 1 ;loop whilst key is held down
LOOP
for aloop = 1 to time ;this loop is for debug purposes - it flashes for however many seconds the key has been held down.
high LED_RED
pause 250
low LED_RED
pause 250
next aloop
if time > 2 AND time < 5 then ;if the key is held down for the appropriate time, then unlock
gosub unlock
endif
return
check_sw_key_release:
if sw_key = 1 then goto check_sw_key_release
return
Can anyone suggest some ideas for a more elegant solution?
On a related note, I tried using the COUNT command with which I had limited success due to debouncing problems. Could I solve the debouncing with something as simple as a capacitor across the key button (it's a simple NO push-button). If so, what value cap should I use?
Thanks in advance.