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.

Keypad 4x4 PIC 18F45K20 with LCD

Status
Not open for further replies.

servntes

New Member
Hi,

Hi, i'm trying to use a LCD with a 4x4 keypad on a PIC18F45K20 to entre values kp and ki and Co.

**broken link removed**

For example:

display on LCD (kp = ...) and Using the keypad

we enter any value of kp, for example (kp = 0 or 12 or 45... .. 100) and validate

by pressing '='

Then display (ki = ...) is also using the keyboard, also we enter any value of ki for example (ki = 0 or 12 or 45... .. 100) and validate by pressing '#'

And finally the same thing for the value of Co = .... and validate by pressing '='

And the key 'ON/c' if we want to delete a number before validate kp or ki or Co

Keys '/' and 'x' and '+' and '-' unused

I want your help !!!
 
What language?

Do you know what you have to do?

I use a Language C and I want to programme a keypad 4x4

display kp= and Using the keypad

we enter any value of kp, for example (kp = 0 or 12 or 45... .. 100) and validate

by pressing '='

I already display kp on LCD, It remains the keypad
 
I don't think you can program the keypad, you will have to program the PIC, could post the code you already have?
 
Last edited by a moderator:
Here is my keypad code with auto repeat.
Code:
int keys,previous,edges;
char KeyCount;

#define KeyDelay 30;
#define KeyRepeat 10;

char ReadKeyPad(){
char i;
rom char KeyPad[16]=  "*7410852#963dcba";
    previous=keys;
    wpub|=0x0f;
    keys=0;
    portb=0;
    for(i=4;i<8;i++){
        keys<<=4;
        trisb|=0xf0;
        trisb&=255-(1<<i);
        keys|=portb&0x0f;
    }
    keys^=0xffff;
    if(keys==0)
        return(0);
    if(((keys^previous)&keys)==0){
        //repeating key
        if(--KeyCount!=0)
            return(0);
        KeyCount=KeyRepeat;
    }else{
        //must be new key
        KeyCount=KeyDelay;
        edges=((keys^previous)&keys);
    }
    i=0;
    while((edges&(1<<i))==0){
        i++;
    }
    i=KeyPad[i];
    return i;
}

You will have to swap around the characters in the table but apart from that it should work as is.

It should be called every 10mS to prevent debounce problems.

Mike.
 
As always Pommie that is very neat code. I like it!
 
That is an excellent example keypad function! It's elegant, cohesive, comprehensive and worthy of an article (wish I had time) to help newcomers and old-timers alike. And unlike the examples in some tutorials, it correctly handles TRIS for only one output at a time while scanning the matrix.

Bravo Mike (Pommie)!
 
Last edited:
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top