 |
:: استاذ و مشرف قسم الالكترونيات ::
تاريخ التسجيل: May 2007
المشاركات: 6,832
|
|
نشاط [ F.Abdelaziz ]
قوة السمعة:
|
|
03-05-2015, 03:32 AM
المشاركة 47
|
|
مشروع قفل إلكترونى بسيط باستخدام ذاكرة EEPROM بالميكروكونترولر ولوحة مفاتيح وشاشة LCD
مشروع قفل إلكترونى بسيط باستخدام ذاكرة EEPROM بالميكروكونترولر ولوحة مفاتيح وشاشة LCD :
الأدوات المستخدمة فى برنامج المحاكاة ISIS : PIC16F877A , KEYPAD , RES , BD135 , CELL , RELAY .
الدائرة الكهربية :

البرنامج :
كود:
#include <16F877a.h>
#use delay(clock= 4000000)
//#use standard_io(a)
#define use_portb_kbd TRUE
#define use_portb_lcd TRUE
#include <lcd.c>
#include <kbd.c>
//#include <stdlib.h>
#rom 0x2100={'7','2','3'} // Save data 7 , 2 , 3 in position 0,1 and 2 of the EEPROM respectively
void main() {
char k;
int i;
char data[3], key[3]; //Storage arrays for data and key
lcd_init();
kbd_init();
port_b_pullups(TRUE);
while (TRUE) {
i=0; //array index position
printf(lcd_putc,"\fPress Key 1\n"); //clear screen , print Press Key 1 , go to a new line
while(i<=2){ //Three data
k=kbd_getc(); //Read keypad
if (k!=0) //If any key is Pressed
{data[i]=k; //It is stored in the corresponding position
i++; //of the array
printf(lcd_putc,"\fPress Key %u\n",i+1); //Next item
}
}
for (i=0;i<=2;i++) { //EEPROM passes data to the key array
key[i]=read_eeprom(i);}
if ((data[0]==key[0])&&(data[1]==key[1])&&(data[2]==key[2]))
{ printf(lcd_putc,"\fDoor Open"); //Compares the data with the key
output_high(PIN_A0); //If equal gives pulse to relay
delay_ms(2000);
output_low(PIN_A0);}
else printf(lcd_putc,"\fDoor Closed"); //key error
delay_ms(1000);
}
}
|