debouncing matrix keypad code

#1
I am using a 40X1 and a 3x4 Matrix Keypad. I need to debounce the return values.
I have had success debouncing single input buttons but not a matrix configuration.

here is part of the code:
<code><pre><font size=2 face='Courier'>
Keyscan:
let key_value = 9
high portc 4
gosub key_test
low portc 4
if key_value&lt;&gt;9 then process

let key_value = 6
high portc 5
gosub key_test
low portc 5
if key_value&lt;&gt;6 then process

let key_value = 3
high portc 6
gosub key_test
low portc 6
if key_value&lt;&gt;3 then process

let key_value = 0
high portc 7
gosub key_test
low portc 7
if key_value&lt;&gt;0 then process

Process:
if key_value&lt;&gt;0 then
sertxd (#Key_Value,13,10)
endif
return

Key_test:
if pin1 = 1 then let Key_value=key_value+1 endif
if pin2 = 1 then let Key_value=key_value+2 endif
if pin3 = 1 then let Key_value=key_value+3 endif
return

</font></pre></code>
 

boriz

Senior Member
#2
Just off the top of my head:

I think one of the simplest mods to this code would be to just repeat the whole procedure a few times with a small delay between each attempt. If all the readings are the same, then you have a debounced output. Two or three repeats should suffice.
 
#3
I usually get my students to add a piezo sounder and send a sound command to it when a keypress is detected. This gives a delay which debounces and also gives the user audible feedback that they have registered the keypress.
 
Top