Smart Parking System Using Arduino Uno

Smart Parking System Using Arduino Uno

Hello everyone!

Today, we will learn how to design a smart parking system using HC-SR04 ultrasonic sensor, servo motor, buzzer, LCD, and Arduino Uno.

Constraints and Conditions took under consideration -

Ø  The ultrasonic sensor module place near the gate entrance continuously checks for the incoming vehicles. The LCD display “Smart Parking” on the first row and “Avail. slot: XY” on the second row of the display.

Ø  When a vehicle comes closer to the ultrasonic sensor detection area and parking slot is available then the system open a gate the barrier to 90° (close after 10 seconds) to allow the vehicle to the parking slot and decrement parking slot by 1.

Ø  If no parking slot is available then display a message “No Parking slot” on LCD (2nd line) and switch on the buzzer (for 5 Seconds). Have a similar system on the exit and increment the free slot by 1 for every vehicle that leaves the parking slot.

Simulate and verify this logic on Arduino Uno using the Tinkercad circuits simulator.

Note: XY is the number of available slots and initially assume the total available parking slot is 15

 

API REQUIRED-

  1. pinMode(x,y) - It will set the pin x in input mode if y=INPUT and in output mode if y=OUTPUT.
  2. pulseIn() - Reads a pulse (either HIGH or LOW) on a pin. lcd.begin(x,y) :- It is used to initialize a LCD with x columns and y rows.
  3. servo.write(angle) - Writes a value to the servo, controlling the shaft accordingly. 
    • angle: the value to write to the servo, from 0 to 180
  4. servo.writeMicroseconds(uS) - Writes a value in microseconds (uS) to the servo, controlling the shaft accordingly.
    • o   uS: the value of the parameter in microseconds (int)
  5. servo.read() - Read the current angle of the servo, The angle of the servo, from 0 to 180 degrees.
  6. servo.attached() – Check whether the Servo variable is attached to a pin. Return true if the servo is attached to pin; false otherwise.
  7. servo.detach() - Detach the Servo variable from its pin. If all Servo variables are detached, then pins 9 and 10 can be used for PWM output with analogWrite().
  8. lcd.begin(x,y) - It is used to initialize an LCD with x columns and y rows.
  9. lcd.clear() - It is used to clear all the contents on the LCD.
  10. lcd.write(x) - It is used to write the value of x on the LCD.
  11. lcd.setCursor(y,x) - It will set the cursor to the y column and x row.
  12.  lcd.print(x) - It is used to print the x on the LCD.


PROGRAM-

#include<Servo.h>

Servo servo_test;

int angle=90;

int count=15;

#include <LiquidCrystal.h>

LiquidCrystal lcd(5, 4, 3, 2, A4, A5);

int trig=12;

int echo=11;

float timeduration;

float distance;

float timeduration1;

float distance1;

void setup(){

   Serial.begin(9600);

   lcd.begin(16, 2);

   lcd.setCursor(0,0);

   Serial.begin(9600);

  pinMode(trig, OUTPUT);

  pinMode(echo,INPUT);

  pinMode(13, OUTPUT);

  pinMode(10,INPUT);

  pinMode(8,OUTPUT);

  servo_test.attach(9);

}

void loop()

{

  servo_test.write(0);

  digitalWrite(trig,LOW);

  delayMicroseconds(2);

  digitalWrite(trig,HIGH);

  delayMicroseconds(10);

  digitalWrite(trig,LOW);

  timeduration=pulseIn(echo,HIGH);

  distance=0.034*(timeduration/2.0);

  digitalWrite(13,LOW);

  delayMicroseconds(2);

  digitalWrite(13,HIGH);

  delayMicroseconds(10);

  digitalWrite(13,LOW);

  timeduration1=pulseIn(10,HIGH);

  distance1=0.034*(timeduration1/2.0);

  if(distance>=30)

  {

    servo_test.write(0);

    lcd.clear();

    lcd.setCursor(0,0);

    lcd.print("Smart Parking");

    lcd.setCursor(0,1);

    lcd.print("Avail. slot:");

    lcd.setCursor(13,1);

    lcd.print(count);

    delay(2000);

  }

  else if(distance<30 && count>0){

    servo_test.write(angle);

    count--;

    lcd.clear();

    lcd.setCursor(0,0);

    lcd.print("Smart Parking");

    lcd.setCursor(0,1);

    lcd.print("Avail. slot:");

    lcd.setCursor(13,1);

    lcd.print(count);

    delay(10000);

    servo_test.write(0);

  }

  else if(count==0)

  {

    lcd.clear();

    lcd.setCursor(0,0);

    lcd.print("Smart Parking");

    lcd.setCursor(0,1);

    lcd.print("No Parking slot");

    digitalWrite(8,HIGH);

    delay(5000);

    digitalWrite(8,LOW);

  }

  if(distance1<30 && count<15){

    count++;

    lcd.clear();

    lcd.setCursor(0,0);

    lcd.print("Smart Parking");

    lcd.setCursor(0,1);

    lcd.print("Avail. slot:");

    lcd.setCursor(13,1);

    lcd.print(count);

    delay(10000);

  }

}


CIRCUIT DIAGRAM & OUTPUTS:

             
Fig1: Required circuit diagram to perform the given task



Fig2: Displaying Available slots, when the available slots are equal to 11


Fig3: Displaying Available slots, when the available slots are equal to 9


Fig4: Displaying No parking slot message, when the available slots are equal to 0




 
TINKERCAD LINK



INFERENCE

    Here, we are using an upper ultrasonic sensor at the entry gate of a car parking system. Whenever an upper ultrasonic sensor detects a car at a distance less than 30 cm then it checks for the empty slot if it is available then it turns the servo motor by 90 degrees for 10 seconds indicating the opening of the gate and also decrease the available parking slots by 1. If distance measured by the upper ultrasonic sensor is less than 30 cm and available parking slot is 0 then the buzzer will become ON for 5 seconds and the display will show “Smart Parking No Parking slot”. Display first row will always show “Smart Parking “and the second column will show “No of parking slot:” with number of available parking slot if available parking slot is greater than 0 otherwise it will show “No parking slot”. Similarly, the lower ultrasonic sensor is at exit gate where if it founds distance to be less than 30 cm and available parking slot < 15 then it will increase the available parking slot by 1.

RESULT

Thus, we have written a required program, designed the required circuit, simulated and verified this logic on Arduino Uno using Tinkercad circuit simulator.




Thanks for Reading!

Written By: Mukul Kumar





  














Comments

Popular posts from this blog

Phishing Attack using SETOOLKIT in Kali Linux

Generate sequence of different waveform using MATLAB