77#include < WebServer.h> // standard library
88
99// input output define
10- #define ULTRA_ONE_TRIG_PIN 23 // ESP32 pin GIOP23 connected to Ultrasonic Sensor's TRIG pin
11- #define ULTRA_ONE_ECHO_PIN 22 // ESP32 pin GIOP22 connected to Ultrasonic Sensor's ECHO pin
10+
11+ #define ULTRA_ONE_TRIG_PIN 33 // ESP32 pin GIOP23 connected to Ultrasonic Sensor's TRIG pin
12+ #define ULTRA_ONE_ECHO_PIN 25 // ESP32 pin GIOP22 connected to Ultrasonic Sensor's ECHO pin
1213#define ULTRA_TWO_TRIG_PIN 17
1314#define ULTRA_TWO_ECHO_PIN 16
1415#define PIN_LED 2 // On board LED
1516#define PIN_OUTPUT 26 // connected to nothing but an example of a digital write from the web page
16-
17+ #define ENTRY_SERVO_PIN 32
18+ #define EXIT_SERVO_PIN 19
1719
1820#define USE_INTRANET
1921#define AP_SSID " Parking-System"
2022#define AP_PASS " pass12345"
2123
2224
2325int servoPosi = 0 ;
24- int EnteryservoPin = 18 ;
25- int ExitservoPin = 19 ;
26+
2627
2728bool LED0 = false , SomeOutput = false ;
2829int entry_gate_distance = 0 ;
@@ -76,10 +77,10 @@ void setup() {
7677 ESP32PWM::allocateTimer (2 );
7778 ESP32PWM::allocateTimer (3 );
7879 entry_gate_servo.setPeriodHertz (50 ); // standard 50 hz servo
79- entry_gate_servo.attach (EnteryservoPin , 500 , 2400 ); // attaches the servo on pin 18 to the servo object
80+ entry_gate_servo.attach (ENTRY_SERVO_PIN , 500 , 2400 ); // attaches the servo on pin 18 to the servo object
8081
8182 exit_gate_servo.setPeriodHertz (50 ); // standard 50 hz servo
82- exit_gate_servo.attach (ExitservoPin , 500 , 2400 ); // attaches the servo on pin 18 to the servo object
83+ exit_gate_servo.attach (EXIT_SERVO_PIN , 500 , 2400 ); // attaches the servo on pin 18 to the servo object
8384
8485 // begin serial port
8586 Serial.begin (9600 );
@@ -135,14 +136,12 @@ void loop() {
135136 // in my example here every 50 ms, i measure some analog sensor data (my finger dragging over the pins
136137 // and process accordingly
137138 // analog input can be from temperature sensors, light sensors, digital pin sensors, etc.
138- if (( millis () - SensorUpdate) >= 50 ) {
139+
139140 // Serial.println("Reading Sensors");
140141 SensorUpdate = millis ();
141- Serial.print (" SensorUpdate:" );
142- Serial.println (SensorUpdate);
143142 exit_gate_distance = get_distance (ULTRA_TWO_TRIG_PIN, ULTRA_TWO_ECHO_PIN);
144143 entry_gate_distance = get_distance (ULTRA_ONE_TRIG_PIN, ULTRA_ONE_ECHO_PIN);
145- }
144+
146145 if (entry_gate_distance <= 10 && cars_num < 10 && !entry_open) {
147146 cars_num++;
148147 entry_open_time = millis ();
@@ -159,6 +158,9 @@ void loop() {
159158
160159 Serial.print (" Cars Number: " );
161160 Serial.println (cars_num);
161+ Serial.print (" Cars Number: " );
162+ Serial.println (exit_gate_distance);
163+
162164
163165 // Entry Gate Moving control
164166 // check if the gate in open state to open it gradully
@@ -182,7 +184,6 @@ void loop() {
182184 entry_moving_time = millis ();
183185 }
184186 }
185-
186187 // Exit Gate Moving control
187188 // check if the gate in open state to open it gradully
188189 if (exit_open
0 commit comments