Continue to Site

Welcome to

Welcome to our site! is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

PIC18F452 and keypad encoder

Not open for further replies.


Newbie level 5
Aug 20, 2009
Reaction score
Trophy points
Activity points
I have to interface a jeypad amongst other things to a PIC18F452. Instead of using 7 pins i decided to use a keypad encoder, namely the MM74C922N.

As i test i linked up the keypad and then PIC. I put capacitor values of 0.1uF and 1uF for the debounce and read capacitor values, and i supplied a 5V supply to the MM74C922, and sent the data to PORTD0:3, and directly wrote the values to PORTB, but didnt get anything on the PORTB LEDs.

is there anything im doing wrong?does anyone know how to use the encoder?do i need to construct any other circuits with the encoder, because the datasheet has some other circuits in the applications section, so i dont know wht to use.


Well I'm sure there is similar Aussy saying, but I think you are doing things backwards way round, - to be polite :D

Using a keyboard encoder onto a Pic really doesn't stack up unless your pic is so overloaded with other tasks, which is unlikely.

There are many web examples of pic to matrix keyboards, start with the Microchip application notes.

Hard to comment on what you have done as you do not give any details of your hardware, program or what compliler you are using.

Are you just using Proteus at the moment or do you actually have the parts ?


well, we can connect the keypad directly to the PIC, but then it has to be polled right?and i dont know whether we can afford to be regularly checkin the ports for changes in the keypad...

i have the actual equipment with me, and am using MPLAB and using the C18 compiler..i got proteus too, but got to get it working properly..
btw, do you know how to use proteus with C?


Am sure your pic will have time to check the Ports, its only a couple of instructions, typically using PortB as that has interrupt options, like Interrupt on change and the pullup resistors option.

Use assembler but cannot see using C makes much difference, just select 'Debugger' then 'Proteus VSM' and then build your project and hit the green button to open the VSM screen.

You will need to Open your previously created DSN but don't expect VSM to run 100% true as there are many quirks to it which can take a lot of effort to find out about.

Its often better to usethe hardware with Debugger Pikit2 or ICD2 if you have one - you can build a cheap diy Pickit2 from the Pickit2 Lite plans on this forum.

so do you suggest i use the keypad without the encoder?

and if i use it without the keypad, can i use it with PORTB, and use the PORTB change interrupt?i guess i can send either the columns or rows to PORTB and then check for change if i use interrupts?

and do i hav to add pull up resistors, or is that not needed?how do i activate the pull up option in PORTB if i use it?

i already got myself a picdem2+ board and the icd2 which means i more or less have all the hardware i need.


Sounds like you have got a great little system there.

To answer your questions - basically Yes to all of them - its just that there are several ways you can wire / program the keypad.

Afraid I cannot suggest the exact way to use it as I'm not into C, but I expect there is a module in C18 ready to do just that.
Also look at the example designs in Proteus, think I saw a keypad somewhere, not sure if the code was in C though.

Haven't got a Picdem2 but sure it will have come with a few discs that contain many tutorials and help files such as Tips and Tricks, the same with C18 which does have a tutorial - they are all free downloads from Microchips site anyway.

If you are still stuck trying to get going, come back and perhap some other members who know C will come in and help - if no one does I know someone who knows a little C and may help out.

Added after 2 hours 58 minutes:


Have also sent you a PM *******************************************************************

Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to