-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCode.C
204 lines (199 loc) · 3.42 KB
/
Code.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
#include<reg51.h>
sbit r1= P1^0; //the size of dialpad is 4 rows and 3 column//
sbit r2= P1^1;
sbit r3= P1^2;
sbit r4= P1^3;
sbit c1= P1^4;
sbit c2= P1^5;
sbit c3= P1^6;
// 4*3 keypad connection //
sbit rs=P3^0;
sbit rw=P3^1;
sbit en=P3^2;
//line 10-12 lcd control lines //
sbit motp=P3^3;
sbit motn=P3^4;
//line 14-15 motor connection//
void lcdcmd(unsigned char);
void lcddat(unsigned char);
void lcddis(unsigned char *,unsigned char);
void delay();
void check();
//line 17-21 function calling//
unsigned char pwd[10],x;//password is stores in the array pwd//
void main()
{
lcdcmd(0x38); // 2 line
lcdcmd(0x01); // Clear display screen //
lcdcmd(0x10); // shift cursor position to left //
lcdcmd(0x0c); // Display on,Cursor off //
lcdcmd(0x80); // Force cursor to beginning to 1st line //
lcddis("PASSWORD PROTECTION",19);
lcdcmd(0xc0); // Force cursor to beginning of 2nd line //
lcddis("SYSTEM",7);
lcdcmd(0x01);
lcddis("ENTER PASSWORD",14);
lcdcmd(0xc0);
while (1)
{
r1=0;
if(c1==0)
{
pwd[x] ='1';
delay();delay();delay();delay();delay();delay();
delay();delay();delay();delay();
delay();delay();
lcddat('*');
x=x+1;
}
if(c2==0)
{
pwd[x] ='2';
delay();delay();delay();delay();delay();delay();
delay();delay();delay();delay();
delay();delay();
lcddat('*');
x=x+1;
}
if(c3==0)
{
pwd[x] ='3';
delay();delay();delay();delay();delay();delay();
delay();delay();delay();delay();
delay();delay();
lcddat('*');
x=x+1;
}
r2=0;r1=1;
if(c1==0)
{
pwd[x] ='4';
delay();delay();delay();delay();delay();
delay();delay();delay();delay();
delay();delay();
lcddat('*');
x=x+1;
}
if(c2==0)
{
pwd[x] ='5';
delay();delay();delay();delay();delay();
delay();delay();
delay();delay();
lcddat('*');
x=x+1;
}
if(c3==0)
{
pwd[x] ='6';
delay();delay();delay();delay();delay();
delay();delay();delay();
delay();delay();
lcddat('*');
x=x+1;
}
r3=0;r2=1;
if(c1==0)
{
pwd[x] ='7';
delay();delay();delay();delay();delay();
delay();delay();delay();delay();
lcddat('*');
x=x+1;
}
if(c2==0)
{
pwd[x] ='8';
delay();delay();delay();delay();delay();
delay();delay();delay();delay();
delay();delay();
lcddat('*');
x=x+1;
}
if(c3==0)
{
pwd[x] ='9';
delay();delay();delay();delay();delay();
delay();delay();delay();delay();
delay();delay();
lcddat('*');
x=x+1;
}
r4=0;r3=1;
if(c1==0)
{
pwd[x] ='*';
delay();delay();delay();delay();delay();
delay();delay();
delay();delay();
lcddat('*');
x=x+1;
}
if(c2==0)
{
pwd[x] ='0';
delay();delay();delay();delay();delay();
delay();delay();
delay();delay();
lcddat('*');
x=x+1;
}
if(c3==0)
{
check();
delay();
delay();
}
r4=1;
}
}
void check()
{
if(pwd[0]=='6' && pwd[1]=='2' && pwd[2]=='3' && pwd[3]=='8' && pwd[4]=='6' && pwd[5]=='3'
&& pwd[6]=='0' && pwd[7]=='0' && pwd[8]=='2' && pwd[9]=='1')
{
motp=1;
motn=0;
lcdcmd(0x01);
lcddis("PASSWORD MATCHED",16);
delay();
}
else
{
lcdcmd(0x01);
lcddis("PASSWORD WRONG",14);
}
}
void lcdcmd(unsigned char val)
{
P2=val;
rs=0;
rw=0;
en=1;
delay();
en=0;
}
void lcddat(unsigned char dat)
{
P2=dat;
rs=1;
rw=0;
en=1;
delay();
en=0;
}
void lcddis(unsigned char *s,unsigned char r)
{
unsigned char w;
for(w=0;w<r;w++)
{
lcddat(s[w]);
delay();
}
}
void delay()
{
unsigned int i,j;
for(i=0;i<4000;i++);
for(j=0;i<100;j++);
}