The Wayback Machine - https://web.archive.org/web/20240707061049/https://www.geeksforgeeks.org/smart-parking-system-using-arduino/
Open In App

Smart Parking System Using Arduino

Last Updated : 30 Apr, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

Arduino is an open-source electronics platform comprising hardware and software components. It was created to make it easier for non-experts, such as artists, designers, and hobbyists, to work with electronics and create interactive projects. The platform includes an easy-to-use development board, a software development environment, and a community that shares projects, ideas, and resources.

Car Parking System Using Arduino

we will learn how to make a Smart Parking System using Arduino. That will only open its gate for parking when there is an available space. If the parking lot is full, the gate will remain closed, and a message will be displayed on the LCD screen indicating the parking is full. Additionally, each parking slot will have a display indicating whether it is currently occupied or vacant.

Components Required for Car Parking System

  • Arduino Uno: Microcontroller Board
  • Servo Motor: Used for opening and closing the gate
  • 2 Bread Boards: Used for connecting the components
  • 5 IR Sensors: They will detect the presence of the car
  • 16*2 LCD: Used to display the number of empty slots
  • Jumper Wires: For connecting the elements of the circuit
  • Potentiometer : Used for the balancing of the lcd display so that it display info in correct intensity

Circuit Diagram of Car Parking System

Let’s discuss the architecture of the project. At the very beginning, a sensor is placed to detect the presence of a car. Depending on the availability of parking slots, the gate (in this case, a servo motor) will open.

WhatsApp-Image-2024-01-22-at-212229_1117487f-(2)

Circuit Diagram

Case 1: if the slots are not available (i.e., the parking is full), the LCD display will show that the parking is full, and the gate will remain closed.

Case 2: if the slots are available, the gate will open. When the car passes in front of the second infrared sensor, it will act as an indication that the car is now in a parking lot, and the gate will close.

After that, based on the particular available slot, the car will be parked, and the LCD display will show the corresponding information.

Pins Connection of Car Parking System

1. LCD Pin Connection

  • Pin 1 (VDD Pin): Ground
  • Pin 2 (VCC Pin): 5V
  • Pin 3 (VEE pin): Connected to the middle pin of the potentiometer for contrast adjustment; other two pins of the potentiometer connected to 5V and Ground.
  • Pin 4 (Register Pin): Connected to Arduino Pin 12.
  • Pin 5 (Read and Write Pin): Connected to Ground.
  • Pin 6: Connected to Arduino Pin 11.
  • Pin 15 (Positive Pin): Connected to 5V.
  • Pin 16 (Negative Pin): Connected to Ground (responsible for LCD backlight)
  • Pin 11 (d4): Connected to Arduino Pin 8.
  • Pin 12 (d5): Connected to Arduino Pin 7.
  • Pin 13 (d6): Connected to Arduino Pin 6.
  • Pin 14 (d7): Connected to Arduino Pin 5.

2. Breadboard and Power Connection

Connect power rails of the Breadboard to Arduino Uno’s 5V and Ground pins..

3. IR Sensor and Servo Motor Connections

  • First IR Sensor:
    • VCC: Connected to 5V
    • GND: Connected to Ground
    • O/P: Connected to Arduino Pin 2
  • Servo Motor:
    • VCC: Connected to 5V
    • GND: Connected to Ground
    • O/P: Connected to Arduino Pin 3
  • Second IR Sensor:
    • VCC: Connected to 5V
    • GND: Connected to Ground
    • O/P: Connected to Arduino Pin 4
  • Remaining IR Sensors:
    • Connect the VCC of each to 5V, GND to Ground, and their O/P pins to Arduino Pins 13, 9, and 10 respectively.

This setup ensures proper connectivity for the LCD, IR sensors, and the servo motor on the breadboard, making it clear and organized for implementation.

Arduino Code of Car Parking System

Now we will do coding for this project setup, where it detects which parking slot is available or unavailable.

// Header Files 
#include <LiquidCrystal.h>
#include <Servo.h>

// Declaring constants for the LCD pins
const int rs = 12, en = 11, d4 = 8, d5 = 7, d6 = 6, d7 = 5;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
Servo myservo1;

//choose the input pin for entry gate IR sensors
int ir_s1 = 2;
int ir_s2 = 4;

//choose the input pin for parking slot IR sensors
int ir_p_1 = 13;
int ir_p_2 = 9;
int ir_p_3 = 10;

int total = 0;
int slot = 3; // Total capacity of the parking
int flag1 = 0;
int flag2 = 0;

int s1 = 0, s2 = 0, s3 = 0;

void setup()
{
Serial.begin(9600); // Initializing the Serial Monitor

//declare sensor as input
pinMode(ir_s1, INPUT);
pinMode(ir_s2, INPUT);
pinMode(ir_p_1, INPUT);
pinMode(ir_p_2, INPUT);
pinMode(ir_p_3, INPUT);

myservo1.attach(3); // attaches the servo on pin 3 to the servo object
myservo1.write(180);

lcd.begin(16, 2); //Initializing the Lcd display
lcd.print("Smart Parking"); // Initial message display on the screen
delay(5000); //It will provide the delay of 5000 milliseconds
lcd.clear(); // after delay clearing the lcd display
}

void loop()
{

read_sensor();

/* When working with a 16x2 LCD display, it means you can write up to 16 characters horizontally and have 2 rows.
The indexing for these rows and characters starts from 0.
*/
lcd.setCursor(0, 0);
lcd.print("Have Slots:");
lcd.print(slot);

lcd.setCursor(0, 1);
if (s1 == 1) {
lcd.print("s1:F");
}
else {
lcd.print("s1:E");
}

lcd.setCursor(5, 1);
if (s2 == 1) {
lcd.print("s2:F");
}
else {
lcd.print("s2:E");
}

lcd.setCursor(10, 1);
if (s3 == 1) {
lcd.print("s3:F");
}
else {
lcd.print("s3:E");
}

// Here the logic begins for opening and closing the gate i.e. servo motor
if (digitalRead(ir_s1) == 0 && flag1 == 0)
{

if (slot > 0)
{
flag1 = 1;
if (flag2 == 0)
{
myservo1.write(90);
slot = slot - 1;
}
}
else
{
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Parking ");
lcd.setCursor(0, 1);
lcd.print("Full ");
// delay(5000);
delay(1500);
}
}

if (digitalRead(ir_s2) == 0 && flag2 == 0)
{
flag2 = 1;
if (flag1 == 0)
{
myservo1.write(90);
slot = slot + 1;
}
}
if (flag1 == 1 && flag2 == 1)
{
delay(1000);
myservo1.write(180);
flag1 = 0;
flag2 = 0;
}
delay(10);
}

void read_sensor() //function for keeping track of the parking slots status
{
s1 = 0, s2 = 0, s3 = 0;
if (digitalRead(ir_p_1) == 0) {
s1 = 1;
}
if (digitalRead(ir_p_2) == 0) {
s2 = 1;
}
if (digitalRead(ir_p_3) == 0) {
s3 = 1;
}
}

Output:

Conclusion

This project demonstrates how Arduino can be used to create a smart parking system. By integrating IR sensors, a servo motor, and an LCD display, we can efficiently manage parking spaces and automate gate control. This system enhances convenience and optimizes parking utilization, showcasing the practical applications of Arduino in real-world scenarios.



Similar Reads

Smart SunLight detection using Arduino
In our daily technological advancements we should utilize the renewable sources like sun ,wind, water etc. Particularly for the solar energy the operations and applications are huge. For the applications of solar energy we should monitor and optimize the solar powered systems using these types of embedded systems. So in here we will use Arduino ,LD
8 min read
Smart Collision Detector using Arduino
Arduino is an open-source electronics platform based on easy-to-use hardware and software. Arduino boards can read digital &amp; analog inputs from the sensors and the HR SC-04 Ultrasonic sensor uses sonar to find the distance between objects. It can measure distances ranging from 2cm to 400cm with an accuracy of 0.3cm. Collision detector is a valu
4 min read
Designing Parking Lot (Garage) System | System Design
Parking garage plays an important role in today's world, as the number of vehicles is increasing every day, so it has become a major concern to manage them. The parking garage provides the solution to this problem of limited space. It offers to book a Parking garage using any method whether online or offline. In this article, we will explore all th
11 min read
How to make Motion Detection System using Arduino?
Arduino is an open-source electronics platform based on easy-to-use hardware and software. Arduino boards can read digital &amp; analog inputs from the sensors and The PIR sensor is a special type of sensor which is usually used for security purposes. It detects the objects by reading the Infrared radiations emitted by the objects. Any object whose
2 min read
Traffic Light Control Project using Arduino
Arduino is an open-source electronics platform based on easy-to-use hardware and software. Arduino boards can read digital &amp; analog inputs from the sensors. With Arduino, you can write and upload computer code to a physical programmable circuit board (commonly called a microcontroller which is ATmega328P 8-bit Microcontroller) using a piece of
3 min read
How to make Smoke Detection Alarm using Arduino?
Arduino is an open-source electronics platform based on easy-to-use hardware and software. Arduino boards can read digital &amp; analog inputs from the sensors and The MQ2 smoke sensor is sensitive to smoke gases like LPG, Butane, Propane, Methane, Alcohol, Hydrogen. In this article, We will learn how can we make a Smoke Detector Alarm using Arduin
2 min read
Servo motor Interfacing and Control using Arduino
In this article, we will learn how to interface and control servo motors using Arduino Uno R3. Arduino is an open-source electronics platform. It consists ATmega328P 8-bit Microcontroller. It can be able to read inputs from different sensors &amp; we can send instructions to the microcontroller in the Arduino. It provides Arduino IDE to write code
3 min read
How to make digital voltmeter using Arduino?
Digital VoltmeterVoltmeter is an instrument used to measure the potential difference or voltage (V) between two points of an electric circuit. Voltage is the potential difference between two points. It pushes charged electrons through conducting loop. It is also known as electric pressure, electromotive force or potential difference, etc. The volta
3 min read
Soil Moisture measurement using Arduino and Soil Moisture Sensor
In This Article, We will learn how to measure the moisture (water content) in soil using the Moisture sensor &amp; Arduino. Arduino is an open-source electronics platform. It consists ATmega328P 8-bit Microcontroller. It can be able to read inputs from different sensors &amp; we can send instructions to the microcontroller in the Arduino. It provid
5 min read
Distance measurement using Ultrasonic sensor and Arduino
In This Article, We will learn how to measure the distance using an Ultrasonic sensor &amp; Arduino. Arduino:It is an open-source electronics platform. It consists ATmega328 8-bit Microcontroller. It can be able to read inputs from different sensors &amp; we can send instructions to the microcontroller in the Arduino. It provides Arduino IDE to wri
7 min read