const int trigPin1 = 27;
const int echoPin1 = 26;
const int trigPin2 = 2;
const int echoPin2 = 15;
const int trigPin3 = 18;
const int echoPin3 = 5;
const int ledPin1 = 13;
const int ledPin2 = 12;
const int ledPin3 = 14;
long duration;
int distance;
void setup () {
pinMode(trigPin1, OUTPUT);
pinMode(echoPin1, INPUT);
pinMode(trigPin2, OUTPUT);
pinMode(echoPin2, INPUT);
pinMode(trigPin3, OUTPUT);
pinMode(echoPin3, INPUT);
pinMode(ledPin1, OUTPUT);
pinMode(ledPin2, OUTPUT);
pinMode(ledPin3, OUTPUT);
Serial.begin(9600);
}
void loop() {
digitalWrite(trigPin1, LOW);
delayMicroseconds(2);
digitalWrite(trigPin1, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin1, LOW);
duration = pulseIn(echoPin1, HIGH);
distance = duration * 0.034 / 2;
if (distance < 200) {
digitalWrite(ledPin1, LOW);
Serial.println("Parking Space 1 : Occupied");
}else {
digitalWrite(ledPin1, HIGH);
Serial.println("Parking Space1 : Vacant");
}
delay(1000);
Serial.print("Distance");
Serial.println(distance);
digitalWrite(trigPin2, LOW);
delayMicroseconds(2);
digitalWrite(trigPin2, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin2, LOW);
duration = pulseIn(echoPin2, HIGH);
distance = duration * 0.034 / 2;
if (distance < 200) {
digitalWrite(ledPin2, LOW);
Serial.println("Parking Space 2 : Occupied");
}else {
digitalWrite(ledPin2, HIGH);
Serial.println("Parking Space2 : Vacant");
}
delay(1000);
Serial.print("Distance");
Serial.println(distance);
digitalWrite(trigPin3, LOW);
delayMicroseconds(2);
digitalWrite(trigPin3, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin3, LOW);
duration = pulseIn(echoPin3, HIGH);
distance = duration * 0.034 / 2;
if (distance < 200) {
digitalWrite(ledPin3, LOW);
Serial.println("Parking Space 3 : Occupied");
}else {
digitalWrite(ledPin3, HIGH);
Serial.println("Parking Space3 : Vacant");
}
delay(1000);
Serial.print("Distance");
Serial.println(distance);
}
esp:VIN
esp:GND.2
esp:D13
esp:D12
esp:D14
esp:D27
esp:D26
esp:D25
esp:D33
esp:D32
esp:D35
esp:D34
esp:VN
esp:VP
esp:EN
esp:3V3
esp:GND.1
esp:D15
esp:D2
esp:D4
esp:RX2
esp:TX2
esp:D5
esp:D18
esp:D19
esp:D21
esp:RX0
esp:TX0
esp:D22
esp:D23
ultrasonic1:VCC
ultrasonic1:TRIG
ultrasonic1:ECHO
ultrasonic1:GND
ultrasonic2:VCC
ultrasonic2:TRIG
ultrasonic2:ECHO
ultrasonic2:GND
ultrasonic3:VCC
ultrasonic3:TRIG
ultrasonic3:ECHO
ultrasonic3:GND
led1:A
led1:C
led2:A
led2:C
led3:A
led3:C