-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathv1.c
208 lines (190 loc) · 3.97 KB
/
v1.c
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
// RFID Based Attendance System Using 8051 Microcontroller
//library description
#include<reg51.h>
#include<string.h>
#include<stdio.h>
#define LCDPORT P1
sbit rs=P1^0;
sbit rw=P1^1;
sbit en=P1^2;
sbit Motor1=P2^4;
sbit Motor2=P2^3;
sbit Speaker=P2^6;
char i,rx_data[50];
char rfid[13],ch=0;
int counter1, counter2, counter3;
unsigned char result[1];
void delay(int itime)
{
int i,j;
for(i=0;i<itime;i++)
for(j=0;j<1275;j++);
}
void daten()
{
rs=1;
rw=0;
en=1;
delay(5);
en=0;
}
void lcddata(unsigned char ch)
{
LCDPORT=ch & 0xf0;
daten();
LCDPORT=(ch<<4) & 0xf0;
daten();
}
void cmden(void)
{
rs=0;
en=1;
delay(5);
en=0;
}
void lcdcmd(unsigned char ch)
{
LCDPORT=ch & 0xf0;
cmden();
LCDPORT=(ch<<4) & 0xf0;
cmden();
}
void lcdstring(char *str)
{
while(*str)
{
lcddata(*str);
str++;
}
}
void lcd_init(void)
{
lcdcmd(0x02);
lcdcmd(0x28);
lcdcmd(0x0e);
lcdcmd(0x01);
}
void uart_init()
{
TMOD=0x20;
SCON=0x50;
TH1=0xfd;
TR1=1;
}
char rxdata()
{
while(!RI);
ch=SBUF;
RI=0;
return ch;
}
void main()
{
Speaker=1;
uart_init();
lcd_init();
lcdstring("---RFID Based---");
lcdcmd(0xc0);
lcdstring("Security System");
delay(500);
lcd_init();
lcdstring("TEAM-3");
lcdcmd(0xc0);
lcdstring("sour-ron-aman");
delay(400);
while(1)
{
lcdcmd(1);
lcdstring("Scan Your Card:");
lcdcmd(0xc0);
i=0;
for(i=0;i<12;i++)
rfid[i]=rxdata();
rfid[i]='\0';
lcdcmd(1);
lcdstring("Rfid No. is:");
lcdcmd(0xc0);
for(i=0;i<12;i++)
lcddata(rfid[i]);
delay(100);
if(strncmp(rfid,"10035AD856C1",12)==0)
{
counter1++;
lcdcmd(1);
lcdstring(" Authorised");
delay(200);
lcdcmd(1);
lcdstring(" Ronit ");
lcdcmd(0xc0);
lcdstring("Member: ");
sprintf(result, "%d", counter1);
lcdstring(result);
Motor1=1;
Motor2=0;
delay(300);
Motor1=0;
Motor2=0;
delay(200);
Motor1=0;
Motor2=1;
}
else if(strncmp(rfid,"1600ADC369A1",12)==0)
{
counter2++;
lcdcmd(1);
lcdstring(" Authorised");
delay(200);
lcdcmd(1);
lcdstring(" Sour ");
lcdcmd(0xc0);
lcdstring("Member: ");
sprintf(result, "%d", counter2);
lcdstring(result);
Motor1=1;
Motor2=0;
delay(300);
Motor1=0;
Motor2=0;
delay(200);
Motor1=0;
Motor2=1;
delay(300);
Motor1=0;
Motor2=0;
}
else if(strncmp(rfid,"1600ABCD147A",12)==0)
{
counter3++;
lcdcmd(1);
lcdstring(" Authorised");
delay(200);
lcdcmd(1);
lcdstring(" Aman ");
lcdcmd(0xc0);
lcdstring("Member: ");
sprintf(result, "%d", counter3);
lcdstring(result);
Motor1=1;
Motor2=0;
delay(300);
Motor1=0;
Motor2=0;
delay(200);
Motor1=0;
Motor2=1;
delay(300);
Motor1=0;
Motor2=0;
}
else
{
lcdcmd(1);
lcdstring("UNAUTHORISED");
lcdcmd(0xc0);
lcdstring("Try Another Card");
Speaker=0;
delay(300);
Speaker=1;
}
}
}