Version:0.9 StartHTML:0000000105 EndHTML:0000011111 StartFragment:0000001072 EndFragment:0000011095
program clave
dim kp,i,j,a as byte 'kp = valor de la tecla presionada
'i = contador de teclas presionadas
'j = contador de asteriscos mostrados
'a = contador de veces acertadas
sub procedure iniciar_Lcd() 'Configuar PORTB como data port
Lcd_Config(PORTB,7,6,5,4,PORTA,0,1,2) 'y PORTA como control port del LCD
Lcd_Cmd(LCD_CURSOR_OFF) 'Apaga Curcor del LCD
end sub
sub procedure Leer_teclado()
Lcd_Cmd(LCD_SECOND_ROW) 'Envia el cursor a Lin 2 Col 1
for j=1 to i
Lcd_Chr_CP("*") 'Imprime * al presionar Tecla
next j
kp=254
while kp=254 'Espera a que se presione una tecla y
kp=Keypad_Released-2 'guarda el dato al soltarla
wend
end sub
main:
Keypad_Init(PORTB)'Inicializa PORTB como controlador del Teclado
while 1
iniciar_Lcd
Lcd_Out_CP("Teclee Clave:") 'Imprime Clave en 1ra Linea
if i=4 then 'Al presionar 4 teclas correctas
Lcd_Cmd(LCD_SECOND_ROW) 'Evia el cursor en Lin 2 Col 1
if a=4 then
if PORTA.3=1 then
for i=0 to 3
iniciar_Lcd
Lcd_Out_CP("Nueva Clave:")
Leer_teclado
EEprom_write(i,kp)
next i
iniciar_Lcd
Lcd_Out_CP("Clave Guardada.")
else
Lcd_Out_CP("Exito!!") 'Exito
end if
else 'de lo contrario se imprimira
Lcd_Out_CP("Error!!") 'Error
end if
delay_ms(1000)
i=0
a=0
continue
end if
Leer_teclado
if EEprom_read(i)=kp then
a=a+1
end if
i=i+1 'incrementa i
wend
end.