-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCar_Parking_System.ino
More file actions
67 lines (52 loc) · 1.14 KB
/
Car_Parking_System.ino
File metadata and controls
67 lines (52 loc) · 1.14 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
#include <LiquidCrystal.h>// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(A0, A1, A2, A3, A4, A5);
#include <Servo.h> //includes the servo library
Servo myservo1;
int ir_s1 = 2;
int ir_s2 = 4;
int Total = 5;
int Space;
int flag1 = 0;
int flag2 = 0;
void setup() {
pinMode(ir_s1, INPUT);
pinMode(ir_s2, INPUT);
myservo1.attach(3);
myservo1.write(100);
lcd.begin(16, 2);
lcd.setCursor (0,0);
lcd.print(" Car Parking ");
lcd.setCursor (0,1);
lcd.print(" System ");
delay (2000);
lcd.clear();
Space = Total;
}
void loop(){
if(digitalRead (ir_s1) == LOW && flag1==0){
if(Space>0){flag1=1;
if(flag2==0){myservo1.write(0); Space = Space-1;}
}else{
lcd.setCursor (0,0);
lcd.print(" Sorry not Space ");
lcd.setCursor (0,1);
lcd.print(" Available ");
delay (1000);
lcd.clear();
}
}
if(digitalRead (ir_s2) == LOW && flag2==0){flag2=1;
if(flag1==0){myservo1.write(0); Space = Space+1;}
}
if(flag1==1 && flag2==1){
delay (1000);
myservo1.write(100);
flag1=0, flag2=0;
}
lcd.setCursor (0,0);
lcd.print("Total Space: ");
lcd.print(Total);
lcd.setCursor (0,1);
lcd.print("Have Space: ");
lcd.print(Space);
}