Repository navigation
Expand file tree
/
Copy pathsmart_parking_code.ino
More file actions
98 lines (82 loc) · 1.6 KB
/
Copy pathsmart_parking_code.ino
File metadata and controls
98 lines (82 loc) · 1.6 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
//#include <Wire.h>
#include<Servo.h>
#include <LiquidCrystal_I2C.h>
// Set the LCD address to 0x27 for a 16 chars and 2 line display
LiquidCrystal_I2C lcd(0x27, 16, 2);
Servo ser;
int ir_car1=6;
int ir_car2=7;
int ir_p1 = 3;
int ir_p2 = 4;
int x1;
int x2;
int x3;
int x4;
int c1 =0;
int c2 =0;
int total;
int slot =2;
int ledr =13;
int ledy =12;
int buzz=11;
void setup()
{
Serial.begin(9600);
// initialize the LCD
lcd.init();
lcd.setCursor(0,0);
lcd.backlight();
lcd.display();
pinMode(ledr,OUTPUT);
pinMode(ledy,OUTPUT);
pinMode(buzz,OUTPUT);
ser.attach(5);
}
void loop()
{
x1 =digitalRead(ir_car1);
x2 =digitalRead(ir_car2);
x3 =digitalRead(ir_p1);
x4 =digitalRead(ir_p2);
if (x1==0){
c1=1;
}
else{
c1=0;
}
if (x2==0){
c2=1;
}
else{
c2=0;
}
total = c1+c2;
if ((slot-total)==0){
lcd.setCursor(0,0);
lcd.print("Parking is full");
delay(2000);
lcd.clear();
}
else{
lcd.setCursor(0,0);
lcd.print("The slot left");
lcd.setCursor(6,1);
lcd.print(slot-total);
delay(2000);
lcd.clear();
}
if ((slot-total) <= 0){
ser.write(0);
delay(20);
}
else if (x3==0 or x4==0){
ser.write(90);
delay(10);
digitalWrite(ledr,1);
}
else{
ser.write(0);
delay(10);
digitalWrite(ledr,0);
}
}