Double click & long press keyboard

Discussion in 'Embedded Systems and Microcontrollers' started by, Mar 14, 2014.


    Thread Starter Member

    Feb 27, 2014
    I am interfacing four keys to AT89C51. I am using pull-up resistor for it. So that pins are high when switch is open & low when switch is pressed.
    I took reference from mazidi & made keypad routine in C & works fine for me.
    Mazidi gave 4x4 keypad algo & I used it to work for individual switches on four pins.
    With every press one variable is incremented.

    With few more tweaks I am able to detect single click & if key is kept pressed then input gets incremented fast.

    Now I wanted to learn how I can implement difference between single & double click.
    keys pressed for short time & keys pressed for long time.

    1. Any reference algo for it.
    2. When interfacing keys with pull-up resistors, should I decouple that pin with 0.1uF capacitor also.
  2. MrChips


    Oct 2, 2009
    Find a microcontroller that has interrupts on change inputs. For example, the MS9S08QG8 has an 8-pin Keyboard Interrupt module that can respond to both edge triggered and level triggered interrupts.

    I would not use capacitor on the input pins for noise or switch bounce reduction. Noise can be eliminated via software.