1#include <LiquidCrystal.h>
2LiquidCrystal lcd(7, 6, 5, 4, 3, 2);
3#include <Servo.h>
4Servo rservo;
5int a=0;
6int b=0;
7int c=9;
8int d=0;
9int e=11;
10int f=0;
11void setup()
12{
13 lcd.begin(16, 2);
14 Serial.begin(9600);
15 rservo.attach(8);
16 pinMode(13, OUTPUT);
17 pinMode(9, INPUT);
18 pinMode(12, OUTPUT);
19 pinMode(11, INPUT);
20}
21
22void loop()
23{
24 d=digitalRead(c);
25 f=digitalRead(e);
26if(d==1)
27{
28 f==0;
29 delay(2000);
30
31}
32 else if(f==1)
33{
34 d==0;
35 delay(2000);
36
37}
38 if(a==0)
39{
40 lcd.setCursor(1,0);
41 lcd.print("0 Person");
42 rservo.write(0);
43 a=1;
44 b=0;
45}
46 else if((d==1)&&(a==1))
47{
48 lcd.setCursor(1,0);
49 lcd.print("1 Person");
50 rservo.write(45);
51 delay(2500);
52 rservo.write(0);
53 digitalWrite(12, HIGH);
54 delay(1000);
55 digitalWrite(12, LOW);
56 a=2;
57 b=4;
58}
59 else if((d==1)&&(a==2))
60{
61 lcd.setCursor(1,0);
62 lcd.print("2 Person");
63 rservo.write(45);
64 delay(2500);
65 rservo.write(0);
66 digitalWrite(12, HIGH);
67 delay(1000);
68 digitalWrite(12, LOW);
69 a=3;
70 b=3;
71}
72else if((d==1)&&(a==3))
73{
74 lcd.setCursor(1,0);
75 lcd.print("3 Person");
76 rservo.write(45);
77 delay(2500);
78 rservo.write(0);
79 digitalWrite(12, HIGH);
80 delay(1000);
81 digitalWrite(12, LOW);
82 a=4;
83 b=2;
84}
85 else if((d==1)&&(a==4))
86{
87 lcd.setCursor(1,0);
88 lcd.print("4 Person");
89 rservo.write(45);
90 delay(2500);
91 rservo.write(0);
92 digitalWrite(12, HIGH);
93 delay(1000);
94 digitalWrite(12, LOW);
95 a=5;
96 b=1;
97}
98 else if((d==1)&&(a==5))
99{
100 digitalWrite(12, HIGH);
101 delay(1000);
102 digitalWrite(12, LOW);
103 lcd.setCursor(1,0);
104 lcd.print("5 Person");
105 delay(2500);
106 rservo.write(45);
107 delay(2500);
108 rservo.write(0);
109 lcd.setCursor(1,0);
110 a=6;
111 b=0;
112}
113else if((d==1)&&(a==6))
114{
115 rservo.write(0);
116 lcd.setCursor(1,0);
117 lcd.print("Full Capacity");
118 delay(2500);
119 lcd.setCursor(1,0);
120 lcd.print(" ");
121 delay(2500);
122 digitalWrite(12, HIGH);
123 delay(1000);
124 digitalWrite(12, LOW);
125 lcd.print("Full Capacity");
126 delay(2500);
127 lcd.setCursor(1,0);
128 lcd.print(" ");
129 delay(2500);
130}
131 else if((f==1)&&(b==0))
132{
133 lcd.setCursor(1,0);
134 lcd.print(" ");
135 lcd.setCursor(1,0);
136 lcd.print("4 Person");
137 rservo.write(45);
138 delay(2500);
139 rservo.write(0);
140 digitalWrite(13, HIGH);
141 delay(1000);
142 digitalWrite(13, LOW);
143 b=1;
144 a=4;
145}
146 else if((f==1)&&(b==1))
147{
148 lcd.setCursor(1,0);
149 lcd.print("3 Person");
150 rservo.write(45);
151 delay(2500);
152 rservo.write(0);
153 digitalWrite(13, HIGH);
154 delay(1000);
155 digitalWrite(13, LOW);
156 b=2;
157 a=3;
158}
159else if((f==1)&&(b==2))
160{
161 lcd.setCursor(1,0);
162 lcd.print("2 Person");
163 rservo.write(45);
164 delay(2500);
165 rservo.write(0);
166 digitalWrite(13, HIGH);
167 delay(1000);
168 digitalWrite(13, LOW);
169 b=3;
170 a=2;
171}
172 else if((f==1)&&(b==3))
173{
174 lcd.setCursor(1,0);
175 lcd.print("1 Person");
176 rservo.write(45);
177 delay(2500);
178 rservo.write(0);
179 digitalWrite(13, HIGH);
180 delay(1000);
181 digitalWrite(13, LOW);
182 b=4;
183 a=1;
184}
185 else if((f==1)&&(b==4))
186{
187 lcd.setCursor(1,0);
188 lcd.print("0 Person");
189 rservo.write(45);
190 delay(2500);
191 rservo.write(0);
192 digitalWrite(13, HIGH);
193 delay(1000);
194 digitalWrite(13, LOW);
195 b=5;
196 a=0;
197}
198else if((f==1)&&(b==5))
199{
200 rservo.write(0);
201 digitalWrite(13, HIGH);
202}
203 digitalWrite(12, LOW);
204 digitalWrite(13, LOW);
205
206
207
208
209
210
211
212 lcd.setCursor(1,1);
213 lcd.print(" ");
214 delay(100);
215 lcd.setCursor(1,1);
216 lcd.print("Limit 5 Person");
217 delay(1000);
218 lcd.setCursor(1,1);
219 lcd.print(" ");
220 delay(100);
221 lcd.setCursor(1,1);
222 lcd.print("Stay Home");
223 delay(1000);
224 lcd.setCursor(1,1);
225 lcd.print(" ");
226 delay(100);
227 lcd.setCursor(1,1);
228 lcd.print("Stay Safe");
229 delay(1000);
230}