Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com 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.

[50 pts] PIC scrolling a Keypad 4x3

Status
Not open for further replies.

mouzid

Full Member level 5
Joined
Jun 22, 2007
Messages
248
Helped
9
Reputation
18
Reaction score
0
Trophy points
1,296
Activity points
2,876
Hi edabaorder,
I need the assemlly code for scrolling a 4x3 keypad with PIC 16F84.
Please refert me to a functional code or share your the code if you have. I'll give 50 pts for helpers.
Merci.
 

why use assembly.
use MikroC ready made libraries for keypad, also it will give you de-bouncing for protection.
good luck
 

nandhu015 said:
scrolling a 4x3 keypad

Scrolling a keypad????

Please explain

Nandhu

Hi,
In my case I'll require 12 pins of my Microcontroller to have 12 button. Actually a keypd is a matrix of button. It is designed like that in order to minimise the number of pins required to read the pressed key. One trick is scroll this matrix using only 7 pins of the microcontroller. The principle of scrolling ressemble to the one used for Dot LED matrix that is very complex to do in assembbly.
I hope you understood.

Mouzid
 

I think Mouzid means 'scanning' rather than scrolling.

It's easy to do, think of the keypad having rows and columns and when a key is pressed it connects one row to one column.

Decide if you want to drive the columns and read the rows or the other way around. Connect each row to one PIC pin and each column to one PIC pin. Connect a pull-down resistor to each input pin and a low value (100Ω will do) resistor in series with each output pin.

Doing it this way, you can in theory reduce the number of keypad connections to (2 * SQRT(number of keys)) connections.

Your software drives each output high in turn, resetting it back to low as it moves to the next output. Each time you do this, read in the input pins. If no signal is on the input pins, it means no key was pressed. If there is a signal on any input pin, see which it is, and which output was high at the time and from there calculate which row/column intersection the key was on.

Writing the code is easy in any language - have a go yourself.

Brian.
 

Yes betwixt, he wants scan keypad. Now i understand.

Mouzid, There are lot of example all over the net. Search to find one. Better do it yourself which will help you to improve your skills

Happy coding

Nandhu
 

Thank you all for your replies.
I use a PIC16F876 instead of the16f84 now. I used the Keypad_Read function of the C compiler. My Keypad is connected to the PIC (at portC) like shown in the figure below. This work but still there is a problem.
Actually when I press 1 I got 1, 4 gives 2, 7 gives 3, * gives 4, 2 gives 5....etc.
Who can tell me how to connect PIC correctly to the pic such that when I press 1 I got 1, 2 I got 2 ,3 I got 3 ....etc.

Merci.
 

Keypad_Read returns a value in the range 1-16, which uniquely identifies one of the (up to) 16 keys on the attached keypad. It's then up to your code to cross-reference this value with the legend printed on/next to the key.

At best, you could try swapping the row and column connections around so that RC0-2 connect to pins 1-3 on the keypad, and RC4-7 connect to pins A-D, but unless Keypad_Read is doing something unusual in its return value generation, this is likely only going to give you a 1:1 mapping between return value and key legend for keys 1-3 - I'm assuming that the return code is simply generated as (column + ((row - 1) * 4)), so for the 3 column keypad you've got, pressing key 4 (column 1, row 2) would then give a return value of 5, pressing key 7 would give a return value of 9, and so on...
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top