Solved

Interface a 4x4 keypad with a PIC

Posted on 2007-12-05
4
12,367 Views
Last Modified: 2013-12-13
I want to add a 4x4 keypad to a 16F877A, i've made the connections to the pins but I don't know how to decode/write the ASM code.
What I want to do is: when I press 3 on the keypad the PIC will scan the keypad and figure it out it was the '3' key and load it in a variable.


So far I wrote the code for:

;                   RB4             RB5             RB6             RB7
;                   COL1             COL2          COL3         COL4
; RB0 ROW1         1                2                 3                  A
;  
; RB1 ROW2        4                 5                  6                  B
;
; RB2 ROW3        7                 8                  9                   C
;
; RB3 ROW4        *                 0                  #                  D
Setting the pins to the wires.


How to intercept the key pressed ?!


I couldn't find anything on the net that will explain the logistic or how is done step by step.

Could anyone help with a source code explained or some good documentation?

Thanks for your time!
0
Comment
Question by:navaru
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 55

Accepted Solution

by:
Jaime Olivares earned 125 total points
ID: 20417849
Have a look to this project:
http://www.jtcotton.info/papers/PIC%20-%20Digital%20Alarm%20Clock.pdf

it has an lcd and a 4x4 keypad with 16f877 microcontroller, including schematics and assembler code. You can extract the portion of your interest.
0
 

Author Comment

by:navaru
ID: 20417873
OK, i'll take a look at that
0
 
LVL 6

Expert Comment

by:Talmash
ID: 20420951
try:
http://www.sunrom.com/s-16f877a-keypad.html
they have online support as well

0
 
LVL 2

Expert Comment

by:kouroshparsa
ID: 20579946
Easy.
First of all, I suggest you use c rather (if you don't know asm)

You have 2 options:
option1: read the "interrupts" section spec of the pic. Implement a signal change interrupt.

option2: it is easier to just have an infinit loop (no interrupt) that scans the keyboard.

Note: I know from my experience that the fastest click of a button will change the signal for at least 40ms. so this is quite safe.
still you need either a hardware or a software debouncer.
Do it in software. It's much easier.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question