A car parking project is needed to implement in every parking to save us time. There are many simple and intermediate car parking projects available on the internet. But this smart car parking project is done by Arduino Uno. it is very simple but has many features like slot availability in the parking automatic gate.Â
Whenever a car comes to the parking gate the sensor will read this and open the gate if there is a slot available. also, there we are using a 16×2 LCD display which displays every information of the system likewise how many slots available, How many cars are inside the parking, etc.
Introduction
A car parking project is a system that optimizes the things in parking also it can reduce manpower because there is a sensor-based toll gate that can automatically open and close.and many of time we entered in the parking but due to no parking space availability we loss our time. so, to save this time this parking project can also help us.
In this project, we will make the connection and code first then assembled the whole system on the cardboard for a better look and work. To make this awesome car parking project you need to know some electronic basic knowledge and programming. but if you are new to all this stuff you can learn from our website only you need to go to the home page and everything can be available there.
So, there I added some steps to make this project like construction, components required, circuit, and code. and troubleshooting.
Components required
- Arduino Uno
- IR sensor
- Servo motor
- jumper wires
- LCD 16×2
- I2C module for LCD
Arduino Uno is an atmega328p ic-based microcontroller that works like a brain in this Car parking project which got the input from the sensor and sends the instruction to the LCD and servo motor. If you want more information about Arduino you can learn it from our previous article on Arduino.
IR sensor is an infrared sensor which has two components one is a transmitter and another is receiver transmitter transmit the signal and receiver receive the transmitted wave which is reflect back from the car and any other vehicle. and this sensor send this information to the arduinoÂ
Servo motors are the special types of motors used for precise work like how many degrees you want to rotate which can do by a servo motor. there is a lot of servo motor different in size, torque and power application.
I2C module for LCD display is very useful now a days it help to make the connections because there is more the 10 wires in the LCD display which acquired more pins in the arduino that’s why we use this i2c module to make the connections and code easy, only you have to install the i2c LCD library.
Now we have to make the connection according to the circuit diagram.
Car Parking Project Circuit Diagram
Make all the connections according to the given Circuit diagram and upload the given code.
Car Parking Project Code
To make the code you need to Gate the I2C address of your LCD. the address may differ for each i2c module so, you need to get he i2c address first, we have given the code below to get the code. but first you have to download and install the library for I2C communication protocol.Â
I2C address code.Â
// --------------------------------------
// i2c_scanner
//
// Version 1
//Â Â This program (or code that looks like it)
//Â Â can be found in many places.
//Â Â For example on the Arduino.cc forum.
//Â Â The original author is not known.
// Version 2, Juni 2012, Using Arduino 1.0.1
// Â Â Adapted to be as simple as possible by Arduino.cc user Krodal
// Version 3, Feb 26Â 2013
//Â Â V3 by louarnold
// Version 4, March 3, 2013, Using Arduino 1.0.3
//Â Â by Arduino.cc user Krodal.
//Â Â Changes by louarnold removed.
//Â Â Scanning addresses changed from 0...127 to 1...119,
//Â Â according to the i2c scanner by Nick Gammon
//Â Â https://www.gammon.com.au/forum/?id=10896
// Version 5, March 28, 2013
//Â Â As version 4, but address scans now to 127.
//Â Â A sensor seems to use address 120.
// Version 6, November 27, 2015.
//Â Â Added waiting for the Leonardo serial communication.
//
//
// This sketch tests the standard 7-bit addresses
// Devices with higher bit address might not be seen properly.
//
#include <Wire.h>
void setup() {
 Wire.begin();
 Serial.begin(9600);
 while (!Serial); // Leonardo: wait for Serial Monitor
 Serial.println("\nI2C Scanner");
}
void loop() {
 int nDevices = 0;
 Serial.println("Scanning...");
 for (byte address = 1; address < 127; ++address) {
  // The i2c_scanner uses the return value of
  // the Wire.endTransmission to see if
  // a device did acknowledge to the address.
  Wire.beginTransmission(address);
  byte error = Wire.endTransmission();
  if (error == 0) {
   Serial.print("I2C device found at address 0x");
   if (address < 16) {
    Serial.print("0");
   }
   Serial.print(address, HEX);
   Serial.println(" !");
   ++nDevices;
  } else if (error == 4) {
   Serial.print("Unknown error at address 0x");
   if (address < 16) {
    Serial.print("0");
   }
   Serial.println(address, HEX);
  }
 }
 if (nDevices == 0) {
  Serial.println("No I2C devices found\n");
 } else {
  Serial.println("done\n");
 }
 delay(5000); // Wait 5 seconds for next scan
}
After uploading this code open the serial monitor and note the I2C address. now we given the project code and where you need to replace the notes code.
Smart Car Parking Project CodeÂ
// TECHATRONIC.COM Â
 // I2C LIBRARY Â
 //https://github.com/fdebrabander/Arduino-LiquidCrystal-I2C-library Â
 #include <Wire.h>     Â
 #include <LiquidCrystal_I2C.h>  Â
 LiquidCrystal_I2C lcd(0x27,16,2); Â
 #include <Servo.h> Â
 Servo myservo1; Â
 int IR1 = 4; // IR Sensor 1 Â
 int IR2 = 7; // IR Sensor 2 Â
 int Slot = 4;   //Enter Total number of parking Slots Â
 int flag1 = 0; Â
 int flag2 = 0; Â
 void setup() Â
 { Â
 lcd.init();   Â
 lcd.backlight(); Â
 pinMode(IR1, INPUT); Â
 pinMode(IR2, INPUT); Â
 myservo1.attach(9); Â
 myservo1.write(100); Â
 lcd.setCursor (0,0); Â
 lcd.print("  ARDUINO "); Â
 lcd.setCursor (0,1); Â
 lcd.print(" PARKING SYSTEM "); Â
 delay (2000); Â
 lcd.clear(); Â
 } Â
 void loop(){ Â
 if(digitalRead (IR1) == LOW && flag1==0){ Â
 if(Slot>0){flag1=1; Â
 if(flag2==0){myservo1.write(0); Slot = Slot-1;} Â
 }else{ Â
 lcd.setCursor (0,0); Â
 lcd.print(" SORRY :( "); Â
 lcd.setCursor (0,1); Â
 lcd.print(" Parking Full "); Â
 delay (3000); Â
 lcd.clear(); Â
 } Â
} Â
 if(digitalRead (IR2) == LOW && flag2==0){flag2=1; Â
 if(flag1==0){myservo1.write(0); Slot = Slot+1;} Â
 } Â
 if(flag1==1 && flag2==1){ Â
 delay (1000); Â
 myservo1.write(100); Â
 flag1=0, flag2=0; Â
 } Â
 lcd.setCursor (0,0); Â
 lcd.print(" WELCOME! "); Â
 lcd.setCursor (0,1); Â
 lcd.print("Slot Left: "); Â
 lcd.print(Slot); Â
 }
So, here we have given the final code after uploading this code to test your project. there are two IR sensors the first sensor is connected the pin 4 and it should be placed before the servo motor and the second its sensor sh