This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Need help on Keyboard 5x4 Matrix

Hi...

I need a C code for Keyboard 5x4 Matrix interfacing with 89C52. I have tried but cant control debouncing. If anyone could help me, I 'll be thank ful.

  • Do not worry, it's rather simple. The approach can be like this. You read the key states at a certain rate (2 to 5 milliseconds is a reasonable choice) and you compare the actual state with one or several previous states. If it coincides, you take it as "real" key state. If it doesn't, you do not change the "real" state. In my practice good result was obtained with no comparison at all for active state and four consecutive coincidences for passive state. That gives a "soft" key. If you want it to be more tough, you can use 2 and 2.
    Regards,
    Michael.

  • Another simple idea is to poll the switches at rate whose period is longer than the the bounce time. This way, no past history of the switches need to be maintained. I have done a lot of projects using a 50Hz polling rate.