Page 1 of 1

keypad codes in Mikro C

Posted: 16 Mar 2015 13:36
by banieban14
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!!!

Re: keypad codes in Mikro C

Posted: 20 Mar 2015 09:19
by filip
Hi,

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

Regards,
Filip.

Re: keypad codes in Mikro C

Posted: 24 Mar 2015 07:56
by banieban14
yes but we need the codes that is like a cellphone keypad

Re: keypad codes in Mikro C

Posted: 25 Dec 2016 12:24
by emerson
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.
}
}

Re: keypad codes in Mikro C

Posted: 26 Dec 2016 17:51
by lana.arsic
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