Şifreli tuş takımı şifre değiştirme ccs commpiler, Hafıza kaydetmmeli pina01 deki tuşa basarak yeni şifre girişi yapılıyor.
#include<18f4550.h>
#device adc=10
#fuses intrc_io,nowdt,nomclr
#use delay(clock=4m)
#define use_portd_kbd
#define use_portb_lcd true
#include<lcd.c>
#include <kbd.c>
char n[5];
char k;
char a,b,c,d;
int cont = 1;
void parola(void);
#int_ad
void yeni_parola(void)
{
parola();
disable_interrupts(global);
}
void main(void)
{
write_eeprom(1,'1');
write_eeprom(2,'2');
write_eeprom(3,'3');
write_eeprom(4,'4');
a= read_eeprom(1);
b= read_eeprom(2);
c= read_eeprom(3);
d= read_eeprom(4);
set_tris_a(0xff);
setup_adc_ports(an0);
setup_adc(adc_clock_internal);
enable_interrupts(int_ad);
set_adc_channel(0);
enable_interrupts(global);
lcd_init();
kbd_init();
lcd_putc("Parola:\n");
while(true)
{
if(input(pin_a1))
{
read_adc();
delay_ms(50);
}
if(cont < 5)
{
k = kbd_getc();
if(k != 0)
{
lcd_putc("*");
n[cont] = k;
delay_ms(100);
cont++;
}
}
if(cont == 5)
{
delay_ms(100);
cont=1;
if(n[1] == a && n[2] == b && n[3] == c && n[4] == d)
{
output_toggle(pin_e2);
printf(lcd_putc,"\f%c,%c,%c,%c",a,b,c,d);
delay_ms(2000);
lcd_putc("\fDogru parola\n");
delay_ms(2500);
lcd_putc("\fparola:\n");
}
else
{
delay_ms(1500);
lcd_putc("\f");
cont=1;
lcd_putc("Yanlis Parola");
delay_ms(2500);
lcd_putc("\fparola:\n");
}
}
}
}
void parola (void)
{
lcd_putc("\fparola eski\n");
while(cont < 5)
{
k = kbd_getc();
if(k != 0)
{
lcd_putc("*");
n[cont] = k;
delay_ms(100);
cont++;
}
}
if(n[1] == read_eeprom(1) && n[2] == read_eeprom(2) && n[3] == read_eeprom(3) && n[4] == read_eeprom(4))
{
cont =1;
lcd_putc("\fparola yeni\n");
while(cont < 5)
{
k = kbd_getc();
if(k != 0)
{
lcd_putc("*");
n[cont] = k;
delay_ms(100);
write_eeprom(cont,n[cont]);
cont++;
}
a= read_eeprom(1);
b= read_eeprom(2);
c= read_eeprom(3);
d= read_eeprom(4);
}
}}
Hiç yorum yok:
Yorum Gönder
Her yorum bilgidir. Araştırmaya devam...