Hi all!
My project will be using a bunch of buttons, and that debounce code is everything but neat..
So im trying to figure out other ways to measure the buttons (simple momentary push buttons, directly connected to arduino nano digital pins, with pull-up resistors active).
The idea is to tie each button to its dedicated digital pin, but also, thru a schottky diode (have a bunch), connect it to a analog pin.
So all the buttons (about 6 in total) are connected to D3 thru D9, as well as A0 (thru 6 schottky diodes), to isolate each "channel".
The idea is then to read the digital pin(thisPin) AND analog pin 0, if A0 is NOT between 1V and 3.5V, (schottky voltage drop of about 0.5v, 1v margin of error, project is on 5V) detect the button as is, if LOW; then PRESSED.
else if A0 = 1-3.5v, repeat read_inputs block
To explain in a different way, the analog pin is supposed to detect a floating signal (not Vss or Vcc), and if it detects a floating signal, it nullifies the digital pin read, forcing the program to repeat the read input block.
Now, the question is; will this actually work?
Will a analog read, in combination with a digital read (on the same button) result in a non-bouncing input signal?
Ive had a similar idea, but instead of the analog pin, tie the schottky diodes to digital pin 2 or 3, witch supports interrupts.
I would then be able to use interrupt to initiate the read_input codeblock, and compare thisPinRead with interruptPinRead, if same, then allrightie then, else button is bouncing.
Since i figure that eventually, the bouncing will stop, rendering the interuptpin and thisPin equal, witch in turn returns the correct button state.
Would this be a better option? If so, why? If not, why? (im trying to learn here.. )
Are there other ways to eliminate the button debounce issue?
I´ve seen some suggestions towards hardware debouncing, how much PCB real-estate does it cost?
Is it unfeasible for most projects, or is it just a few SMD parts?