-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
109 lines (98 loc) · 1.89 KB
/
main.c
File metadata and controls
109 lines (98 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#include"display_driver.h"
#include<string.h>
#define a 1<<12
#define b 1<<13
UC8 rfid_dat[15];
UC8 rfid_data[5][14] = {"030067849F7A","477326494638","478326494638",
"478326494637","06003B683762"};// list of allowed rfid card
UC8 rfid_flag = 0;
UC8 byte_no = 0;
UC8 uart0_rx(void)
{
while(((U0LSR)&1)== 0);
return(U0RBR);
}
void check_rfid(void)
{
UC8 check_flag = 0,i;
IODIR0 |=a|b;// p0.2 and p0,3 as output pin
//IOSET0 = a|b; // for led
for(i = 0;i<5;i++)
{
if(strcmp(rfid_dat,rfid_data[i])== 0)
{
check_flag = 1;
break;
}
}
if(check_flag == 0)
{
LCD_INIT();
LCD_CMD(0x80);
LCD_STR("ACCESS DENIED");
delaym(2000);
LCD_CMD(0x01);
}
else
{
LCD_CMD(0x01);
LCD_CMD(0x80);
LCD_STR("ACCESS APROVED");
delaym(100);
//rotate the motor to one directiono
LCD_CMD(0x01);
LCD_CMD(0x80);
LCD_STR("DOOR IS OPENING");
IOSET0 = a; //for motor
IOCLR0 = b; //for motor
delaym(5000);// for 5 second
LCD_CMD(0x01);
LCD_CMD(0x80);
LCD_STR("DOOR IS OPEN");
IOCLR0 = a|b;
delaym(2000);
//rotate the motor to another direction
LCD_CMD(0x01);
LCD_CMD(0x80);
LCD_STR("DOOR IS CLOSING");
IOSET0 = b; //for motor
IOCLR0 = a;// for motor
delaym(5000);
}
byte_no = 0;
LCD_CMD(0X01);
LCD_CMD(0X80);
IOSET0 = a|b; // for led
}
void UART0_CONFIG(void){
U0LCR=0X83;
U0DLL=97;
U0DLM=0;
U0LCR=0X03;
}
int main( )
{
U32 count = 0,c = 0;
PINSEL0=0X5;
UART0_CONFIG();
LCD_INIT();
LCD_CMD(0x80);
LCD_STR("V25CE2A1");
delaym(2000);/// delay
LCD_CMD(0X01); //clear
LCD_CMD(0x80);///
LCD_STR("Access Control system Using RFID");//proj name
delaym(4000);
LCD_CMD(0x01);
while(1)
{
LCD_STR("WAVE THE CARD");
while(byte_no<12)
{
rfid_dat[byte_no]= uart0_rx();
byte_no++;
}
rfid_dat[byte_no]= '\0';
check_rfid();
}
}