2-Wire Keypad Interface Using a 555 Timer. Part 3 Connecting to the PIC16F628A, Software, Demonstration

Part 1. Theory and Schematic

Part 2. Frequency and Pulse outputs, Significance of Rp and Cp values, Role of Rc resistor

The two outputs from the keypad are connected to the PIC16F628A microcontroller. The pulse output goes to RA2 pin whereas the frequency output goes to RA4/T0CKI input of the microcontroller. A standard character LCD module is also connected to the microcontroller to display what key is pressed. I have also connected an LED with a 470R resistor in series at the output of 555 (not shown in the circuit diagram) so that it glows every time a key is pressed.

keypad are connected to the PIC16F628A microcontroller
Click to enlarge

Software

I have written a sample test program with MikroC compiler that uses Timer0 module to count the external pulses from the 555 timer output. The program polls for a pulse signal at RA2 pin, and when the pulse is detected, the Timer0 module is activated for 100 ms and the number of overflows is recorded. The pressed key is displayed on a 16×2 character LCD. You can download the source code and HEX file here.

I have got some feedbacks in past few days regarding this technique, and most of them say this would be hard from programming perspective. But let me tell you this. The microcontroller needs a program no matter you use the matrix keypad and scan rows/columns, or use a resistor divider network technique and write the program to read and compare the ADC values for the pressed key. I would say the programming part for this technique is not that hard, as I said you don’t have to deal with calculating any frequency here. You just need to enable a timer for a fixed interval (I am using 100 ms, and of course the key has to be pressed for at least that long) when a key press is detected. Then, the information regarding the pressed key is given by the number of times the timer is overflown. Here’s the flowchart of how this works.

Demonstration

Downloads

Source Code (mikroC from mikroElektronika) and hex - download

embedded-lab.com