Smart Barrier Gate Model [ With Improved Safety & Traffic Alert ]
This Simple Project explains how to build a model design of a barrier gate system with improved safety & traffic alert feature.
When a vehicle entered in to the waiting area, the Ultrasonic sensor -01 detects it and informs the gate officer through the LCD module. Driver can also check whether the vehicle is entered in to the waiting area properly from the indication lamp. (Yellow LED)
Gate officer can use button -1 to open the gate(Servo -90 degrees). The LCD module displays the gate is opened .Note that the gate will only be opened if there is a vehicle in the waiting area.(Green LED will be ON)
While the vehicle is passing through the gate, if by accident the gate is to be closed(button -2 pressed), the ultrasonic sensor -02 will immediately detect it and the gate will be opened(Servo -90 degrees). LCD Module will display the gate is blocked.(RED LED will be ON)
If the button -2 is pressed when there is no vehicle passing through(ultrasonic sensor -02 is LOW), the gate will return to initial position (0 degrees).
If there is no any activity in the gate area ;Gate will remain in its initial position(servo -0 degrees), LCD module will display No activity alert.(All LEDs will be OFF).
Tools & Components
1 X Arduino nano1 X Metal Gear Servo Motor
2 X Ultrasonic Sensor
2 X Push Buttons
1 X 16x2 LCD Module
1 X 10K Ohm Potentiometer
2 X 2.2K Ohm Resistors
1 X Red LED
1 X Yellow LED
1 X Green LED
5VDC Power Supply
Connecting Wires
Connecting Components
Sensor Positions
NOTE :
Distance between Ultrasonic sensor -01 & front facing vertical plane should be higher than 15cm.(otherwise Change it in the code)
Distance between Ultrasonic sensor -02 & horizontal plane(Ground) should be higher than 10cm.(otherwise Change it in the code)
Ultrasonic Sensor 01 (Waiting Area) Trig. Pin - Arduino Pin D4
Ultrasonic Sensor 01 (Waiting Area) Echo Pin - Arduino Pin D3
Ultrasonic Sensor 02 (Gate) Trig. Pin - Arduino Pin D6
Ultrasonic Sensor 02 (Gate) Echo Pin - Arduino Pin D5
LCD Module D7 - Arduino Pin A7
LCD Module D6 - Arduino Pin A6
LCD Module D5 - Arduino Pin A5
LCD Module D4 - Arduino Pin A4
LCD Module E - Arduino Pin D13
LCD Module RS - Arduino Pin A3
LCD Module Vcc - +5V
LCD Module Vss - GND
LCD Module LED(-) - GND
LCD Module LED(+) - +5V
LCD Module VEE - Potentiometer Sig. Pin
Push Button (Gate Up) - Arduino Pin D12
Push Button (Gate Down) - Arduino Pin D11
Arduino Code
//2020 CraftyBin.blogspot.com//Author : Chathura H.
#include <LiquidCrystal.h>
#include <Servo.h>
Servo myservo;
#include <HCSR04.h>
UltraSonicDistanceSensor distanceSensor1(4, 3);
UltraSonicDistanceSensor distanceSensor2(6, 5);
LiquidCrystal lcd(A3, 13, A4, A5, A6, A7);
int Red = 9;
int Green = 7;
int Yellow = 8;
int up = 12;
int down =11;
int count = 0; // current display count
void setup() {
Serial.begin(9600);
lcd.begin(16, 2);
myservo.attach(10);
pinMode(Red,OUTPUT);
pinMode(Green,OUTPUT);
pinMode(Yellow,OUTPUT);
pinMode(up,INPUT);
pinMode(down,INPUT);
}
void loop() {
Serial.print("Sensor 01 = ");
Serial.println(distanceSensor1.measureDistanceCm());
Serial.print("Sensor 02 = ");
Serial.println(distanceSensor2.measureDistanceCm());
Serial.print("UP = ");
Serial.println(digitalRead(up));
Serial.print("DOWN = ");
Serial.println(digitalRead(down));
Serial.println("");
if (distanceSensor1.measureDistanceCm() <= 15 && digitalRead(up) == LOW && distanceSensor2.measureDistanceCm() >= 10) {
digitalWrite(Yellow,HIGH);
digitalWrite(Green ,LOW);
digitalWrite(Red ,LOW);
lcd.print("Alert : Waiting For Departure ");
delay(500);
lcd.clear();
delay(1);
}
else if (distanceSensor1.measureDistanceCm() <= 15 && digitalRead(up) == HIGH){
myservo.write(90);
digitalWrite(Green,HIGH);
digitalWrite(Yellow ,LOW);
digitalWrite(Red ,LOW);
lcd.print("Alert : Gate Opened ");
delay(500);
lcd.clear();
delay(1);
}
else if (digitalRead(down) == HIGH && distanceSensor2.measureDistanceCm() >= 10){
myservo.write(0);
digitalWrite(Green,LOW);
digitalWrite(Yellow ,HIGH);
digitalWrite(Red ,LOW);
lcd.print("Alert : Gate Closed ");
delay(500);
lcd.clear();
delay(1000);
}
else if (digitalRead(down) == HIGH && distanceSensor2.measureDistanceCm() <= 10){
myservo.write(90);
digitalWrite(Red,HIGH);
digitalWrite(Yellow ,LOW);
digitalWrite(Green ,LOW);
lcd.print("Alert : Gate Blocked ");
delay(500);
lcd.clear();
delay(1);
}
else if (distanceSensor2.measureDistanceCm() <= 10){
myservo.write(90);
digitalWrite(Red,HIGH);
digitalWrite(Green ,LOW);
digitalWrite(Yellow ,LOW);
delay(1000);
lcd.print("Alert : Gate Blocked ");
delay(500);
lcd.clear();
delay(1);
}
else if (distanceSensor1.measureDistanceCm() >= 15 && distanceSensor2.measureDistanceCm() >= 10 && digitalRead(up)==LOW && digitalRead(down) ==LOW){
myservo.write(0);
digitalWrite(Yellow,LOW);
digitalWrite(Green ,LOW);
digitalWrite(Red ,LOW);
lcd.print("Alert : No Activity ");
delay(500);
lcd.clear();
delay(1);
}
}
Safety First !Always Connect the power supply if you are absolutely sure that the components are connected correctly without changing polarity and short circuited the wiring.Even if it seems nothing is wrong : DOUBLE CHECK EVERYTHING !Your Feedback is very important to us.Please Leave a comment about how you feel about this project.
You make so many great points here that I read your article a couple of times. Your views are in accordance with my own for the most part. This is great content for your readers. automatic driveway gates
ReplyDeleteThis particular is usually apparently essential and moreover outstanding truth along with for sure fair-minded and moreover admittedly useful My business is looking to find in advance designed for this specific useful stuffs… Open gate with cell phone
ReplyDeleteRecently I read your blog and it was very good. I'm really impressed with this blog. This content was really appreciated. Thanks for sharing this type of blog Window grills hand railing
ReplyDeleteThis is very educational content and written well for a change. It's nice to see that some people still understand how to write a quality post.! Garage doors san diego
ReplyDeletePost a Comment