Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

SERIAL KEYPAD 4X4 help

Status
Not open for further replies.

JiggyPepper

New Member
Guys I haven't any experience with using a keypad so please bear with me and my possible noobish questions.

Basically, I am trying to interface a keypad with a microcontroller.

MikroC will be used for the codes.
MCU is PIC16F877A.
Keypad is 4x4.

Since the keypad is serial, it'll be connected to the Rx Terminal of the PIC. But MikroC's keypad library seems to be for a parallel 4x4 keypad. Besides the initialization of the UART port, I'm at a lost.

I want to write conditions such as if key 'a' is pressed, execute this. But I'm having trouble with "identifying" the "variables" sent by the keypad (variable to use in my if statements). Can anyone enlighten me on this, or serial keypad help in general will be much appreciated.

Sorry if this might sound stupid or lacking, I'm relatively new to programming and MCUs.
 
I'm not an expert, and don't use MicroC, but You need to setup the uart port to match the keypad speed / etc, you don't need the keypad lib.
When you rx data from the keypad you have to setup a check / match and then go to a routine to handle your input.
You can just poll the uart or use interrupts.
Hope this helps some.
 
This should help you understand the output of the keypad encoder. The encoder may be part of the keypad assembly.

The output depends on which keypad encoder you are using.

One that seems to be in common use is the EDE 1144, datasheet.
The EDE1144 encoder generates the following codes.
'0' '1' '2' '3'
'4' '5' '6' '7'
'8' '9' 'A' 'B'
'C' 'D' 'E' 'F'
You will need to map the codes to the characters on your keypad. This is most clearly illustrated using a switch/case construct.
View attachment 61387
In the following code c is the value from the encoder, and d is the value that matches what the user pressed on the keypad.

Code:
 switch(c)
    {
      case '0':  // 1 2 3
      case '1':
      case '2':
        d = c+1;
        break;
      case '4': // 4 5 6
      case '5':
      case '6':
        d = c;
        break;
      case '8': // 7 8 
      case '9':
        d = c-1;
        break;
      case 'A':  // 9
        d = '9';
        break;
      case 'C':  // Clear KEY
        d = '*';
        break;
      case 'D':  // 0
        d = '0';
        break;
      case 'F':  // Enter Key
        d = '#';
        break;
      default:  // Up, Down, Help, and unexpected values are errors
        fail = 1;
        d = '~';
    }
 
Last edited:
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top