Docsity

keypad for pic16f877a, Guías, Proyectos, Investigaciones de Electrónica

Toggle sidebar
bg1
E.I.S. “PEDRO DOMINGO MURILLO”
CARRERA: ELECTRÓNICA
NIVEL: SUPERIOR
ASIGNATURA: MIC – 400 paralelo “B”
MICROCONTROLADORES I
LABORATORIO Nº
TEMA: KEYPAD Y LCD
(personalizado)
FECHA DE REALIZACIÓN:
OBJETIVO
Implementar una aplicación utilizando la librería keypad y la librería LCD. El teclado es de 4 filas
y 4 columnas.
PREINFORME
1. Indicar todas las características del teclado matricial a utilizarse.
2. Personalizar su teclado por grupo o persona.
3. Explicar detalladamente el programa desarrollado en mikroBasic.
LABORATORIO
Implementar el Diagrama mostrado en la figura. Demostrar su funcionamiento.
program Keypad_Test
dim kp, cnt, oldstate as byte
txt as char[7]
' Conexiones del módulo del teclado
dim keypadPort as byte at PORTC
' Fin de las conexiones del módulo de teclado
' Conexiones del módulo LCD
dim LCD_RS as sbit at RB4_bit
LCD_EN as sbit at RB5_bit
LCD_D4 as sbit at RB0_bit
LCD_D5 as sbit at RB1_bit
LCD_D6 as sbit at RB2_bit
LCD_D7 as sbit at RB3_bit
LCD_RS_Direction as sbit at TRISB4_bit
LCD_EN_Direction as sbit at TRISB5_bit
LCD_D4_Direction as sbit at TRISB0_bit
LCD_D5_Direction as sbit at TRISB1_bit
LCD_D6_Direction as sbit at TRISB2_bit
LCD_D7_Direction as sbit at TRISB3_bit
' Fin de las conexiones del módulo LCD
main:
oldstate = 0
cnt = 0 ' Reset Contador
Keypad_Init() ' Inicializa Keypad
adcon1 = 6 ' Puertos A y E como entrada y salida digital
Lcd_Init() ' Inicializa LCD
Lcd_Cmd(_LCD_CLEAR) ' Clear display
Lcd_Cmd(_LCD_CURSOR_OFF) ' Cursor off
Lcd_Out(1, 1, "Key :") ' Escribir mensaje de texto en el LCD
pf3
pf4

Vista previa parcial del texto

¡Descarga keypad for pic16f877a y más Guías, Proyectos, Investigaciones en PDF de Electrónica solo en Docsity!

E.I.S. “PEDRO DOMINGO MURILLO”

CARRERA: ELECTRÓNICA

NIVEL: SUPERIOR

ASIGNATURA: MIC – 400 paralelo “B” MICROCONTROLADORES I

LABORATORIO Nº

TEMA: KEYPAD Y LCD

(personalizado) FECHA DE REALIZACIÓN: OBJETIVO Implementar una aplicación utilizando la librería keypad y la librería LCD. El teclado es de 4 filas y 4 columnas. PREINFORME

  1. Indicar todas las características del teclado matricial a utilizarse.
  2. Personalizar s u teclado por grupo o persona.
  3. Explicar detalladamente el programa desarrollado en mikroBasic. LABORATORIO Implementar el Diagrama mostrado en la figura. Demostrar su funcionamiento. program Keypad_Test dim kp, cnt, oldstate as byte txt as char[7] ' Conexiones del módulo del teclado dim keypadPort as byte at PORTC ' Fin de las conexiones del módulo de teclado ' Conexiones del módulo LCD dim LCD_RS as sbit at RB4_bit LCD_EN as sbit at RB5_bit LCD_D4 as sbit at RB0_bit LCD_D5 as sbit at RB1_bit LCD_D6 as sbit at RB2_bit LCD_D7 as sbit at RB3_bit LCD_RS_Direction as sbit at TRISB4_bit LCD_EN_Direction as sbit at TRISB5_bit LCD_D4_Direction as sbit at TRISB0_bit LCD_D5_Direction as sbit at TRISB1_bit LCD_D6_Direction as sbit at TRISB2_bit LCD_D7_Direction as sbit at TRISB3_bit ' Fin de las conexiones del módulo LCD main: oldstate = 0 cnt = 0 ' Reset Contador Keypad_Init() ' Inicializa Keypad adcon1 = 6 ' Puertos A y E como entrada y salida digital Lcd_Init() ' Inicializa LCD Lcd_Cmd(_LCD_CLEAR) ' Clear display Lcd_Cmd(_LCD_CURSOR_OFF) ' Cursor off Lcd_Out(1, 1, "Key :") ' Escribir mensaje de texto en el LCD

Lcd_Out(2, 1, "Times:") while TRUE kp = 0 'Reset el código de la variable key ' Espere a que se presione y suelte la tecla while ( kp = 0 ) kp = Keypad_Key_Click() ' Almacena el código en la variable kp Wend ' Prepara el valor para la salida, transforma key a su valor ASCII select case kp case 1 kp = 49 ' 1 ' Bloque para keypad 4x case 2 ' 147* kp = 50 ' 2 ' 2580 case 3 ' 369# kp = 51 ' 3 ' ABCD case 4 kp = 65 ' A case 5 kp = 52 ' 4 case 6 kp = 53 ' 5 case 7 kp = 54 ' 6 case 8 kp = 66 ' B case 9 kp = 55 ' 7 case 10 kp = 56 ' 8 case 11 kp = 57 ' 9 case 12 kp = 67 ' C case 13 kp = 42 ' * case 14 kp = 48 ' 0 case 15 kp = 35 ' # case 16 kp = 68 ' D end select if (kp <> oldstate) then 'La tecla presionada es diferente de la anterior cnt = 1 oldstate = kp

(^23) RA0/AN0RA1/AN (^4) RA2/AN2/VREF-/CVREF (^67) RA4/T0CKI/C1OUTRA5/AN4/SS/C2OUT (^89) RE0/AN5/RDRE1/AN6/WR (^10) RE2/AN7/CS (^1314) OSC1/CLKINOSC2/CLKOUT RC1/T1OSI/CCP2RC2/CCP1 (^1617) RC3/SCK/SCL 18 RD0/PSP0RD1/PSP1 (^1920) RB7/PGDRB6/PGC 40 RB5 3938 RB3/PGMRB4 37 RB2 3635 RB0/INTRB1 34 33 RD7/PSP7RD6/PSP6 30 RD5/PSP5 2928 RD4/PSP4RD3/PSP3 27 RD2/PSP2 2221 RC7/RX/DTRC6/TX/CK^26 RC5/SDO 2524 RC4/SDI/SDA 23 (^5) RA3/AN3/VREF+ RC0/T1OSO/T1CKI 15 (^1) MCLR/Vpp/THV U PIC16F877A 1 2 1 CRYSTAL C 22pF C 22pF Vcc D 14 D 13 D 12 D 11 D 10 D 9 D 8 D 7 E 6 RW 5 RS 4 VSS 1 VDD 2 VEE 3 Vcc LCD1 LM016L R 10k 1 2 3 4 5 6 8 9 = 7 C ++ ON (^0) A B C D 1 2 3 4 R1 10k R3 10k R4 10k R5 10k 42% RV 10k