9 Eylül 2020 Çarşamba

ccs c sifreli lcd keypad tek port ile çalışma

Pic programlama ccs c sifreli lcd keypad tek port ile çalışma

#include<16f88.h>
#fuses intrc_io,nomclr
#use delay(clock=4m)
#define use_portb_kbd TRUE
#include<KBD.c>

#define LCD_ENABLE_PIN  PIN_B0                                 
#define LCD_RS_PIN      PIN_B1                             
#define LCD_RW_PIN      PIN_B2
#define LCD_DATA4       PIN_B4                                 
#define LCD_DATA5       PIN_B5                                 
#define LCD_DATA6       PIN_B6                                 
#define LCD_DATA7       PIN_B7

#include<lcd.c>
char anahtar;
char *sifre="7894";
int i=0;
int yanlis=0;



void main()
{
kbd_init();
lcd_init();
printf(lcd_putc,"Sifre:");

while(true)
{
anahtar=kbd_getc();
delay_ms(1);
if(anahtar != 0)
{
printf(lcd_putc,"%c",anahtar);
delay_ms(200);

if(sifre[i] != anahtar)
{
yanlis=1;
}

i++;
}
if(i==4 && yanlis==1)
{
printf(lcd_putc,"\nSifre yanlis");
output_high(pin_a6);
delay_ms(5000);
output_low(pin_a6);
i=0;
yanlis=0;
printf(lcd_putc,"\fSifre:");
}

if(i==4 && yanlis==0)
{
printf(lcd_putc,"\nSifre dogru");
output_high(pin_a7);
delay_ms(5000);
output_low(pin_a7);
i=0;
yanlis=0;
printf(lcd_putc,"\fSifre:");
}
}
}


Hiç yorum yok:

Yorum Gönder

Her yorum bilgidir. Araştırmaya devam...