Está en la página 1de 13

El teclado matricial 4X4

Introduccin

El teclado matricial 4X4


Es un dispositivo de 16 teclas configurado como una matriz (filas-columnas), con la intencin de reducir el nmero de bits de puerto requeridas para controlarlo mediante un micro-controlador.

El teclado matricial 4X4


Conectar botones y salidas a microcontolador

El teclado matricial 4X4


Conectar teclado MATRICIAL a un microcontrolador

El teclado matricial 4X4


INSTRUCCIONES (keypad Lubrary)

Se define el puerto a emplear.

char keypadPort at PORTD;

El teclado matricial 4X4


INSTRUCCIONES (keypad Lubrary)

Keypad_Init ( );

El teclado matricial 4X4


INSTRUCCIONES (keypad Lubrary)

Dentro de la tarea principal del programa:

Keypad_Init ( );

El teclado matricial 4X4


INSTRUCCIONES (keypad Lubrary)

Lee teclado y regresa el dato leido:

Keypad_Key_Click();

El teclado matricial 4X4


INSTRUCCIONES (keypad Lubrary)

Ejemplo:

tecla=Keypad_Key_Click(); If (tecla==1) { Lcd_Chr_CP(49); }

Ejemplo: teclado matricial 4X4

Ejemplo: teclado matricial 4X4


char keypadPort at PORTD; sbit LCD_RS at RB4_bit; sbit LCD_EN at RB5_bit; sbit LCD_D4 at RB0_bit; sbit LCD_D5 at RB1_bit; sbit LCD_D6 at RB2_bit; sbit LCD_D7 at RB3_bit; sbit LCD_RS_Direction at TRISB4_bit; sbit LCD_EN_Direction at TRISB5_bit; sbit LCD_D4_Direction at TRISB0_bit; sbit LCD_D5_Direction at TRISB1_bit; sbit LCD_D6_Direction at TRISB2_bit; sbit LCD_D7_Direction at TRISB3_bit; unsigned short tecla=0; unsigned int numero=0; unsigned char unidades=48; unsigned char decenas=48; char *text; /* -, 1,4,7,*,2,5,8,0,3,6,9,#,A,B,C,D*/ unsigned char matriz[17]={0,49,52,55,42,50,53,56,48,51,54,57,35,65,66,67,68};

Ejemplo: teclado matricial 4X4


void main() { INTCON = 0; // Todas las interrupciones deshabilitadas

Keypad_Init(); Lcd_Init(); Lcd_Cmd(_LCD_CURSOR_OFF); Lcd_Cmd(_LCD_CLEAR);


text = "ITMA UPSLP"; for (numero=0; numero<10; numero=numero+1) { Lcd_Out(1,1,text); Lcd_Cmd(_LCD_SHIFT_RIGHT); Delay_ms(800); } for (numero=0; numero<10; numero=numero+1) { Lcd_Out(1,1,text); Lcd_Cmd(_LCD_SHIFT_LEFT); Delay_ms(800); }

Ejemplo: teclado matricial 4X4


while (1) { do { tecla = 0; tecla = Keypad_Key_Click(); }while (!tecla); Lcd_Out(1,1,text); Delay_ms(100); Lcd_Out(2,1,"Tecla: "); Lcd_Chr_CP(matriz[tecla]); Delay_ms(100); } }}

También podría gustarte