-2

Using MPLAB v3.55 with xc8 compiler. Extreme newbie when it comes to programming and I am trying to figure out a program that helps determine the key that's pressed on the 4x4 matrix keypad (MM74C922) encoder.

All row, column, and output (4bit) pins are connected to microcontroller ports.

Also unsure of another thing, for example, when the code decides that key 1 was pressed making the ABCD output 0000, how does that work in the code. Do I need to write code that says if key 1 is pressed then output=0000? Or is there no programming needed at all? Does it just give the appropriate output when a key is pressed and all you need to do is to connect the pins to the microcontroller? I am lost

enter image description here

Fiidisks
  • 91
  • 5
  • What PIC are using? How is it connected to the MM74C922? What u decide to do in the code is up to you. But yes ...you need code to do anything with the value. – Rodo Nov 12 '21 at 19:44
  • PIC18F4520. No particular connections. So I need to actually code the output? I am confused whether or not the output is just generated on its own depending on the key pressed – Fiidisks Nov 12 '21 at 19:47
  • Well...you need to decide what you're project will do. Wire up the PIC18F4520 and write code to accomplish your project's task(s). You can use DA from MM74C922 to let PIC18F4520 know that there is a keypress available. – Rodo Nov 12 '21 at 19:50
  • The main task is to display the output on an LCD module. Articles online have codes that basically say, if key1 is pressed=1 but in my case my output is 4 bit which is why I am confused – Fiidisks Nov 12 '21 at 19:53
  • What's you background? Connecting an LCD to a PIC is no trivial task. Do you have a breadboard, parts and programmer or are u using a simulator? – Rodo Nov 12 '21 at 19:56
  • How is this different to your previous question? Why don't the answers to your previous question answer this as well? – Justme Nov 12 '21 at 19:59
  • @Rodo No background. Just unsure if programming is needed to generate output or does the MM74C922 already do that for me – Fiidisks Nov 12 '21 at 20:03
  • @Justme Previous questions helped me understand the concept on how it is determined which key was pressed. But now I am unsure if programming is needed to control the output. E.g If key1 is pressed= make output 0000 or does it already automatically do that – Fiidisks Nov 12 '21 at 20:05
  • Please take another look at your previous question, the answer is there already. Read the comments and answers, take a look at the chip diagram what it does. Pay attention to what inputs the chip uses to determine the outputs. – Justme Nov 12 '21 at 20:35
  • @Fiidisks: You write code (compile and program) the PIC (not the 922). Use MPLAB and XC8 to do that. Your code will read the 922 (pins 12,14,15,16,17 connected to the PIC pins) and do something with the value....again according to your code. – Rodo Nov 12 '21 at 21:24
  • @Rodo Lets say those output pins are connected to the microcontroller and I want to use this output data to detect and identify which key was pressed how do I do that? Apparently there is something called the look-up technique but I am unfamiliar – Fiidisks Nov 13 '21 at 07:06
  • You look at the chip datasheet and it tells you which code the chip outputs from each of the buttons in the matrix. Basically same answer than in your first question. – Justme Nov 13 '21 at 10:08

1 Answers1

0

Do I need to write code that says if key 1 is pressed then output=0000? Or is there no programming needed at all?

No, this does the 74C922 for you.

Does it just give the appropriate output when a key is pressed and all you need to do is to connect the pins to the microcontroller?

Correct, connect the outputs A to D to your µC, and react in your code if "data available" gets true. Then read A to D and use the resulting number (0 to 15 decimal, or 0x0 to 0xF in hex) as the key number.

Since "output enable" is hard-wired to "low", the outputs are always "on" and give you "high" or "low".

the busybee
  • 2,140
  • 8
  • 20