Car Parking System Using Arduino
Table of Contents
Toggle IntroductionIn this article, we will explore creating a car parking system using an Arduino microcontroller board, an I2C 20×4 LCD, an MG955 servo motor, and an IR sensor. The parking system will help automate the car parking process by providing real-time information and guiding the driver through the parking space.
We will discuss the components used, their functionalities, and how they work together to create an efficient parking system.
Components NeededS.N
Component's
Quantity
Link To Buy
1
Arduino Uno
1
2
20x4 LCD Display
1
3
IR Sensor
6
4
MG995 Servo Motor
1
5
Wire
20
6
Zero PCB
1
7
9V Power Supply
1
Circuit Diagram- Connect the VCC and GND pins of the IR sensors to the 5V and GND pins of the Arduino board, respectively.
- Connect the signal pins of the IR sensors (ir_enter, ir_back, ir_car1 to ir_car4) to any available digital input pins on the Arduino ( pins 2, 4, 5, 6, 7, 8).
- Connect the signal wire of the servo motor to a digital output pin on the Arduino (pin 3).
- Connect the SDA and SCL pins of the LCD module to the corresponding SDA and SCL pins on the Arduino (A4 and A5 for most Arduino boards).
- Connect the VCC and GND pins of the LCD module to the 5V and GND pins of the Arduino board, respectively.
Once the circuit connections are made, you can upload the provided code to the Arduino board using the Arduino IDE. The code initializes the sensors, servo motor, and LCD in the setup() function. The loop() function continuously reads the sensor inputs, updates the LCD, and controls the servo motor based on the sensor readings.
Source Codejust flow the image and Install the liquid crystal i2c library
//Prateek //https://justdoelectronics.com //https://www.youtube.com/@JustDoElectronics #include <Servo.h> #include <Wire.h> #include <LiquidCrystal_I2C.h> LiquidCrystal_I2C lcd(0x27, 20, 4); Servo myservo; #define ir_enter 2 #define ir_back 4 #define ir_car1 5 #define ir_car2 6 #define ir_car3 7 #define ir_car4 8 int S1 = 0, S2 = 0, S3 = 0, S4 = 0; int flag1 = 0, flag2 = 0; int slot = 4; void setup() { Serial.begin(9600); pinMode(ir_car1, INPUT); pinMode(ir_car2, INPUT); pinMode(ir_car3, INPUT); pinMode(ir_car4, INPUT); pinMode(ir_enter, INPUT); pinMode(ir_back, INPUT); myservo.attach(3); myservo.write(90); lcd.init(); lcd.backlight(); lcd.setCursor(0, 1); lcd.print(" Hi Welcome To "); lcd.setCursor(0, 2); lcd.print(" JustDoElectronics"); delay(5000); lcd.clear(); lcd.setCursor(0, 0); lcd.print(" Today's Project "); lcd.setCursor(0, 1); lcd.print(" Car Parking "); lcd.setCursor(0, 2); lcd.print(" System "); delay(5000); lcd.clear(); Read_Sensor(); int total = S1 + S2 + S3 + S4; slot = slot - total; } void loop() { Read_Sensor(); lcd.setCursor(0, 0); lcd.print(" Available Slot: "); lcd.print(slot); lcd.print(" "); lcd.setCursor(0, 1); if (S1 == 1) { lcd.print("S1:Full "); } else { lcd.print("S1:Empty"); } lcd.setCursor(11, 1); if (S2 == 1) { lcd.print("S2:Full "); } else { lcd.print("S2:Empty"); } lcd.setCursor(0, 2); if (S3 == 1) { lcd.print("S3:Full "); } else { lcd.print("S3:Empty"); } lcd.setCursor(11, 2); if (S4 == 1) { lcd.print("S4:Full "); } else { lcd.print("S4:Empty"); } if (digitalRead(ir_enter) == 0 && flag1 == 0) { if (slot > 0) { flag1 = 1; if (flag2 == 0) { myservo.write(180); slot = slot - 1; } } else { lcd.setCursor(0, 0); lcd.print(" Sorry Parking Full "); delay(1500); } } if (digitalRead(ir_back) == 0 && flag2 == 0) { flag2 = 1; if (flag1 == 0) { myservo.write(180); slot = slot + 1; } } if (flag1 == 1 && flag2 == 1) { delay(1000); myservo.write(90); flag1 = 0, flag2 = 0; } delay(1); } void Read_Sensor() { S1 = 0, S2 = 0, S3 = 0, S4 = 0; if (digitalRead(ir_car1) == 0) { S1 = 1; } if (digitalRead(ir_car2) == 0) { S2 = 1; } if (digitalRead(ir_car3) == 0) { S3 = 1; } if (digitalRead(ir_car4) == 0) { S4 = 1; } } 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 //Prateek//https://justdoelectronics.com//https://www.youtube.com/@JustDoElectronics #include <Servo.h>#include <Wire.h>#include <LiquidCrystal_I2C.h>LiquidCrystal_I2C lcd(0x27, 20, 4); Servo myservo; #define ir_enter 2#define ir_back 4#define ir_car1 5#define ir_car2 6#define ir_car3 7#define ir_car4 8 int S1 = 0, S2 = 0, S3 = 0, S4 = 0;int flag1 = 0, flag2 = 0;int slot = 4; void setup() { Serial.begin(9600); pinMode(ir_car1, INPUT); pinMode(ir_car2, INPUT); pinMode(ir_car3, INPUT); pinMode(ir_car4, INPUT); pinMode(ir_enter, INPUT); pinMode(ir_back, INPUT); myservo.attach(3); myservo.write(90); lcd.init(); lcd.backlight(); lcd.setCursor(0, 1); lcd.print(" Hi Welcome To "); lcd.setCursor(0, 2); lcd.print(" JustDoElectronics"); delay(5000); lcd.clear(); lcd.setCursor(0, 0); lcd.print(" Today's Project "); lcd.setCursor(0, 1); lcd.print(" Car Parking "); lcd.setCursor(0, 2); lcd.print(" System "); delay(5000); lcd.clear(); Read_Sensor(); int total = S1 + S2 + S3 + S4; slot = slot - total;} void loop() { Read_Sensor(); lcd.setCursor(0, 0); lcd.print(" Available Slot: "); lcd.print(slot); lcd.print(" "); lcd.setCursor(0, 1); if (S1 == 1) { lcd.print("S1:Full "); } else { lcd.print("S1:Empty"); } lcd.setCursor(11, 1); if (S2 == 1) { lcd.print("S2:Full "); } else { lcd.print("S2:Empty"); } lcd.setCursor(0, 2); if (S3 == 1) { lcd.print("S3:Full "); } else { lcd.print("S3:Empty"); } lcd.setCursor(11, 2); if (S4 == 1) { lcd.print("S4:Full "); } else { lcd.print("S4:Empty"); } if (digitalRead(ir_enter) == 0 && flag1 == 0) { if (slot > 0) { flag1 = 1; if (flag2 == 0) { myservo.write(180); slot = slot - 1; } } else { lcd.setCursor(0, 0); lcd.print(" Sorry Parking Full "); delay(1500); } } if (digitalRead(ir_back) == 0 && flag2 == 0) { flag2 = 1; if (flag1 == 0) { myservo.write(180); slot = slot + 1; } } if (flag1 == 1 && flag2 == 1) { delay(1000); myservo.write(90); flag1 = 0, flag2 = 0; } delay(1);}void Read_Sensor() { S1 = 0, S2 = 0, S3 = 0, S4 = 0; if (digitalRead(ir_car1) == 0) { S1 = 1; } if (digitalRead(ir_car2) == 0) { S2 = 1; } if (digitalRead(ir_car3) == 0) { S3 = 1; } if (digitalRead(ir_car4) == 0) { S4 = 1; }} Video Conclusion
- With further enhancements, this system can be expanded to handle multiple parking spaces, integrate with mobile applications, or incorporate advanced features like automatic payment systems.
More Arduino Tutorial
- Soil Moisture Sensor With Arduino
- DS18B20 Sensor With Arduino
- Water Level Sensor With Arduino
- Rain Sensor With Arduino
- BMP-180 Sensor With Arduino