Close
0%
0%

Smart Car Barrier System

A mini car barrier system that automatically lifts up when vehicle approaching.

Similar projects worth following
0 followers
The project is about creating a mini car barrier systems by using Ultrasonic sensor and Servo module. When there is vehicle approaching, the barrier will lift up automatically.

This is a mini project to realise the application of the combination of ultrasonic sensor and servo module. The car barrier will automatically lift up when the ultrasonic sensor senses a vehicle coming. 

  • 1 × RTL8722DM_MINI
  • 1 × HC-SR04 Ultrasonic module
  • 1 × Tower Pro SG90 servo module
  • 2 × Paper clips
  • 1 × Blue tag

  • 1
    Circuit Connection

    The circuit connection is as shown in the figure below.

  • 2
    Code
    #include<AmebaServo.h>
    
    AmebaServo myservo;
    const int trigPin=3;
    const int echoPin=5; 
    long duration;
    int distance;
    
    void setup() {
      Serial.begin(9600);
      myservo.attach(9);
      pinMode(trigPin, OUTPUT);
      pinMode(echoPin, INPUT); 
    }
    
    void loop() {
      digitalWrite(trigPin, LOW);
      delayMicroseconds(2);
      digitalWrite(trigPin, HIGH);
      delayMicroseconds(10);
      digitalWrite(trigPin, LOW);
    
    // measure time duration of pulse HIGH at echo pin
    duration=pulseIn(echoPin, HIGH);
    
    // calculate the distance from car to sensor
    distance=(0.034*duration)/2;
    
    if(distance<=10){
      myservo.write(90);
      }
    else{
      myservo.write(0);
      }
      
      Serial.print("distance: ");
      Serial.println(distance);
      Serial.print(" cm");
      delay(1);
    }

View all instructions

Enjoy this project?

Share

Discussions

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates