keypad codes in Mikro C

Post your requests and ideas for the mikroElektronika website & forums.
Post Reply
Author
Message
banieban14
Posts: 2
Joined: 16 Mar 2015 13:14

keypad codes in Mikro C

#1 Post by banieban14 » 16 Mar 2015 13:36

hi!!!to all Im new member here from Philippines, any one can gave some codes in Mikro C. We are making a project that like a cellphone if you press buttom 2 then letter A will appear if you click it twice letter B will appear and A will gone!! Our PIC that we use is PIC16f877 in Proteus and our LCD is 2x16.. with a Keypad of 3x4 cellpone!!!
Tnx to those who help me in my project!!
hoping for your kindness!!!
again Thank you so much!!!
and Good Evening all!!!

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: keypad codes in Mikro C

#2 Post by filip » 20 Mar 2015 09:19

Hi,

You could try the Keypad example in the compiler for this purpose.

Regards,
Filip.

banieban14
Posts: 2
Joined: 16 Mar 2015 13:14

Re: keypad codes in Mikro C

#3 Post by banieban14 » 24 Mar 2015 07:56

yes but we need the codes that is like a cellphone keypad

emerson
Posts: 3
Joined: 24 Dec 2016 20:19

Re: keypad codes in Mikro C

#4 Post by emerson » 25 Dec 2016 12:24

banieban14 wrote:yes but we need the codes that is like a cellphone keypad
si el compañero tiene razón el ejemplo del teclado de phone de mikro c es perfecto, yo tengo algo que te puede guiar, pero te repito es mejor este, es solo agravarle unos cuantos if para poder escribir letras, te dejo este código que tengo de un teclado.

//Declaración del puerto para el teclado 4x4
char keypadPort at PORTC;
//Definicion pines para el LCD.
sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D7 at RB3_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D4 at RB0_bit;
//Definicion de registros TRIS para el LCD.
sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;

sbit LCD_D7_Direction at TRISB3_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D4_Direction at TRISB0_bit;
//Función para decodificar el teclado.
char LeerTeclado( void )
{
//Estructura switch case para evaluar los valores retornados
//por la librería del teclado.
switch( Keypad_Key_Press() )
{
case 1: return '1';
case 2: return '2';
case 3: return '3';
case 4: return 'A';
case 5: return '4';
case 6: return '5';
case 7: return '6';
case 8: return 'B';
case 9: return '7';
case 10: return '8';
case 11: return '9';
case 12: return 'C';
case 13: return '*';
case 14: return '0';
case 15: return '#';
case 16: return 'D';
default: return 0; //Tecla no pulsada.
}
}
void main( void )
{
//Declaración de variables.
char Tecla;
//Configuración e inicialización del PIC.
Lcd_Init(); //Inicializa el LCD.
Lcd_Cmd(_LCD_CURSOR_OFF); //Se apaga el cursor.
Lcd_Out(1, 1,"Tecla:"); //Se imprime texto.
while(1)//Bucle infinito.
{
Tecla=LeerTeclado(); //Se lee el teclado y su resultado se guarda en Tecla.
Lcd_Chr(2,1,Tecla); //Visualización el valor retornado por el teclado.
}
}

User avatar
lana.arsic
mikroElektronika team
Posts: 1715
Joined: 15 Jan 2016 12:50

Re: keypad codes in Mikro C

#5 Post by lana.arsic » 26 Dec 2016 17:51

Hi,

@ banieban14

You can try to use as guide code which emerson has posted.

@ emerson

Thank you for helping our user,
but please next time post in English, since it is rule of the forum,
also on that way the most of our users will understand you.

Best regards,
Lana

Post Reply

Return to “Website & Forums Wishlist”