#include <main.h>
#include <LCD.C>
#include <KBD.C>
#include <stdio.h>
#use delay(clock=4000000)
#include <stdlib.h>
#rom 0x2100={'1','9','7'}
void main()
{ char k;
int x;
int j;
char data[3], clave[3];
lcd_init();
kbd_init();
port_b_pullups(TRUE);
setup_adc_ports(NO_ANALOGS);
printf(LCD_PUTC, "\f");
int i;
lcd_gotoxy(1,1);
printf(LCD_PUTC, "Bienvenido");
delay_ms(1000);
for (i=1;i<=16;++i)
{
lcd_gotoxy(i,2);
printf(LCD_PUTC, "*");
delay_ms( 200 );
}
printf(LCD_PUTC, "\f");
lcd_gotoxy(1,1);
printf(LCD_PUTC, "Cerradura");
lcd_gotoxy(1,2);
printf(LCD_PUTC, "Cerrada");
delay_ms(2000);
printf(LCD_PUTC, "\f");
lcd_gotoxy(1,1);
printf(LCD_PUTC, "ingrese clave");
while(TRUE)
{j=0;
while (j<=2){
k=kbd_getc();
if(k!=0) {
data[j]=k;
j++;
}
}
for (j=0;j<=2;j++){
clave[j]=read_eeprom(j);
}
if ((data[0]==clave[0])&&(data[1]==clave[1])&&(data[2]==clave[2])){
printf(LCD_PUTC, "\f");
lcd_gotoxy(1,1);
printf(LCD_PUTC, "ok");
}
else
printf(LCD_PUTC, "\f");
lcd_gotoxy(1,1);
printf(LCD_PUTC, "clave erronea");
delay_ms(2000);
}
}