Monday, November 30, 2015

Momentary Push Button Debouncing Circuit and LED with Arduino

Further testing of my Arduino based microtonal MIDI converter revealed that for a monophonic synthesizer extra code is required to perform last note retriggering when more than one key is pressed and the keys pressed map to the same MIDI note number (but different pitchbend values).  So I decided to use a momentary push button to toggle between monophonic and polyphonic modes along with an LED to indicate the two modes.

I acquired one of these buttons with a built-in LEDThis page describes well why debouncing is necessary and provides a possible circuit about 2/3 of the way down.  I implemented it according to the below schematic.  The time for this debouncing circuit to discharge is directly proportional to the (external) resistance and the capacitance.  So I chose the largest capacitor in my box of parts: 100 pF, and I chose an (external) resistor value less than the 20 K internal pull-up resistor but still large:  10 K.  These values worked well, so I kept them.

I connected the LED using the below schematic with a 220 ohm current limiting resistor as recommended by adafruit.