el-teclado4x4

13
El teclado matricial 4X4 Introducción

Upload: alberto-martinez

Post on 24-Oct-2014

39 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: El-Teclado4x4

El teclado matricial 4X4

Introducción

Page 2: El-Teclado4x4

El teclado matricial 4X4

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

Page 3: El-Teclado4x4

El teclado matricial 4X4

Conectar botones y salidas a microcontolador

Page 4: El-Teclado4x4

El teclado matricial 4X4

Conectar teclado MATRICIAL a un microcontrolador

Page 5: El-Teclado4x4

El teclado matricial 4X4

INSTRUCCIONES (keypad Lubrary)

Se define el puerto a emplear.

char keypadPort at PORTD;

Page 6: El-Teclado4x4

El teclado matricial 4X4

INSTRUCCIONES (keypad Lubrary)

Keypad_Init ( );

Page 7: El-Teclado4x4

El teclado matricial 4X4

INSTRUCCIONES (keypad Lubrary)

Dentro de la tarea principal del programa:

Keypad_Init ( );

Page 8: El-Teclado4x4

El teclado matricial 4X4

INSTRUCCIONES (keypad Lubrary)

Lee teclado y regresa el dato leido:

Keypad_Key_Click();

Page 9: El-Teclado4x4

El teclado matricial 4X4

INSTRUCCIONES (keypad Lubrary)

Ejemplo:

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

Page 10: El-Teclado4x4

Ejemplo: teclado matricial 4X4

Page 11: El-Teclado4x4

Ejemplo: teclado matricial 4X4char 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};

Page 12: El-Teclado4x4

Ejemplo: teclado matricial 4X4void 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); }

Page 13: El-Teclado4x4

Ejemplo: teclado matricial 4X4while (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); }}}