RAJESH SINHA
Published © CERN-OHL2

Advanced & Smart Parking System V 2.0

"Revolutionizing urban mobility with an Advanced & Smart Parking System, optimising spaces and enhancing user convenience. "

AdvancedFull instructions providedOver 1 day561
Advanced & Smart Parking System V 2.0

Things used in this project

Story

Read more

Schematics

circuit diagram

Schematic

Code

Code for Arduino mega

Arduino
#include <LiquidCrystal_I2C.h>
#include <SoftwareSerial.h>

SoftwareSerial mySerial(52, 53);
LiquidCrystal_I2C lcd(0x27, 20, 4);

const int trig_1 = 2;
const int echo_1 = 3;

const int trig_2 = 4;
const int echo_2 = 5;

const int trig_3 = 6;
const int echo_3 = 7;

const int trig_4 = 8;
const int echo_4 = 9;

const int trig_5 = 10;
const int echo_5 = 11;

const int trig_6 = 12;
const int echo_6 = 13;

const int trig_7 = 14;
const int echo_7 = 15;

const int trig_8 = 16;
const int echo_8 = 17;

const int trig_9 = 18;
const int echo_9 = 19;

const int trig_10 = 22;
const int echo_10 = 23;

const int irSensor1 = 200;  // IR sensor for entry
const int irSensor2 = 500; // IR sensor for exit
const int servoPin = 900;   // Servo motor control pin
const int rotationAngle = 120;

const int carDetectLED_1 = A0;
const int carDetectLED_2 = A1;
const int carDetectLED_3 = A2;
const int carDetectLED_4 = A3;
const int carDetectLED_5 = A4;
const int carDetectLED_6 = A5;
const int carDetectLED_7 = A6;
const int carDetectLED_8 = A7;
const int carDetectLED_9 = A8;
const int carDetectLED_10 = A9;

float distanceCM_1 = 0, resultCM_1 = 0;
float distanceCM_2 = 0, resultCM_2 = 0;
float distanceCM_3 = 0, resultCM_3 = 0;
float distanceCM_4 = 0, resultCM_4 = 0;
float distanceCM_5 = 0, resultCM_5 = 0;
float distanceCM_6 = 0, resultCM_6 = 0;
float distanceCM_7 = 0, resultCM_7 = 0;
float distanceCM_8 = 0, resultCM_8 = 0;
float distanceCM_9 = 0, resultCM_9 = 0;
float distanceCM_10 = 0, resultCM_10 = 0;

long Time_1, Time_2, Time_3, Time_4, Time_5, Time_6, Time_7, Time_8, Time_9, Time_10;
float car_1, car_2, car_3, car_4, car_5, car_6, car_7, car_8, car_9, car_10;
float Dist_1 = 50.0, Dist_2 = 50.0, Dist_3 = 50.0, Dist_4 = 50.0, Dist_5 = 50.0, Dist_6 = 50.0, Dist_7 = 50.0, Dist_8 = 50.0, Dist_9 = 50.0, Dist_10 = 50.0;
int total = 0, timer_cnt = 0;
float parkingFee = 50.0;  // Parking fee

void setup()
{
  mySerial.begin(115200);
  pinMode(trig_1, OUTPUT);
  pinMode(trig_2, OUTPUT);
  pinMode(trig_3, OUTPUT);
  pinMode(trig_4, OUTPUT);
  pinMode(trig_5, OUTPUT);
  pinMode(trig_6, OUTPUT);
  pinMode(trig_7, OUTPUT);
  pinMode(trig_8, OUTPUT);
  pinMode(trig_9, OUTPUT);
  pinMode(trig_10, OUTPUT);

  pinMode(echo_1, INPUT);
  pinMode(echo_2, INPUT);
  pinMode(echo_3, INPUT);
  pinMode(echo_4, INPUT);
  pinMode(echo_5, INPUT);
  pinMode(echo_6, INPUT);
  pinMode(echo_7, INPUT);
  pinMode(echo_8, INPUT);
  pinMode(echo_9, INPUT);
  pinMode(echo_10, INPUT);

  digitalWrite(trig_1, LOW);
  digitalWrite(trig_2, LOW);
  digitalWrite(trig_3, LOW);
  digitalWrite(trig_4, LOW);
  digitalWrite(trig_5, LOW);
  digitalWrite(trig_6, LOW);
  digitalWrite(trig_7, LOW);
  digitalWrite(trig_8, LOW);
  digitalWrite(trig_9, LOW);
  digitalWrite(trig_10, LOW);


  pinMode(carDetectLED_1, OUTPUT);
  pinMode(carDetectLED_2, OUTPUT);
  pinMode(carDetectLED_3, OUTPUT);
  pinMode(carDetectLED_4, OUTPUT);
  pinMode(carDetectLED_5, OUTPUT);
  pinMode(carDetectLED_6, OUTPUT);
  pinMode(carDetectLED_7, OUTPUT);
  pinMode(carDetectLED_8, OUTPUT);
  pinMode(carDetectLED_9, OUTPUT);
  pinMode(carDetectLED_10, OUTPUT);

  lcd.init();
  lcd.backlight();
  lcd.setCursor(0, 0);
  lcd.print("    IoT ENABLED");
  lcd.setCursor(0, 1);
  lcd.print("  PARKING SYSTEM");
  lcd.setCursor(0, 2);
  lcd.print("RAJESH KUMAR(ECE)4th");
  lcd.setCursor(0, 3);
  lcd.print("   JIET JODHPUR");
  delay(4000);
  lcd.clear();
}

void loop()
{
  total = 0;
  car_1 = sensor_1();
  car_2 = sensor_2();
  car_3 = sensor_3();
  car_4 = sensor_4();
  car_5 = sensor_5();
  car_6 = sensor_6();
  car_7 = sensor_7();
  car_8 = sensor_8();
  car_9 = sensor_9();
  car_10 = sensor_10();

  lcd.setCursor(0, 0);
  lcd.print("P1:");
  if (car_1 <= Dist_1)
  {
    digitalWrite(carDetectLED_1, HIGH);
    lcd.print("F,");
  }
  else
  {
    total += 1;
  }
  if (car_1 > Dist_1)
  {
    digitalWrite(carDetectLED_1, LOW);
    lcd.print("E,");
    // displayParkingFee(1);
  }
  // lcd.setCursor(6, 0);
  lcd.print("P2:");
  if (car_2 <= Dist_2)
  {
    digitalWrite(carDetectLED_2, HIGH);
    lcd.print("F,");
  }
  else
  {
    total += 1;
  }
  if (car_2 > Dist_2)
  {
    digitalWrite(carDetectLED_2, LOW);
    lcd.print("E,");
    // displayParkingFee(2);
  }
  // lcd.setCursor(12, 0);
  lcd.print("P3:");
  if (car_3 <= Dist_3)
  {
    digitalWrite(carDetectLED_3, HIGH);
    lcd.print("F,");
  }
  else
  {
    total += 1;
  }
  if (car_3 > Dist_3)
  {
    digitalWrite(carDetectLED_3, LOW);
    lcd.print("E,");
    // displayParkingFee(3);
  }
  // lcd.setCursor(18, 0);
  lcd.print("P4:");
  if (car_4 <= Dist_4)
  {
    digitalWrite(carDetectLED_4, HIGH);
    lcd.print("F");
  }
  else
  {
    total += 1;
  }
  if (car_4 > Dist_4)
  {
    digitalWrite(carDetectLED_4, LOW);
    lcd.print("E");
    // displayParkingFee(4);
  }
  lcd.setCursor(0, 1);
  lcd.print("P5:");
  if (car_5 <= Dist_5)
  {
    digitalWrite(carDetectLED_5, HIGH);
    lcd.print("F,");
  }
  else
  {
    total += 1;
  }
  if (car_5 > Dist_5)
  {
    digitalWrite(carDetectLED_5, LOW);
    lcd.print("E,");
    // displayParkingFee(5);
  }
  // lcd.setCursor(0, 5);
  lcd.print("P6:");
  if (car_6 <= Dist_6)
  {
    digitalWrite(carDetectLED_6, HIGH);
    lcd.print("F,");
  }
  else
  {
    total += 1;
  }
  if (car_6 > Dist_6)
  {
    digitalWrite(carDetectLED_6, LOW);
    lcd.print("E,");
    // displayParkingFee(6);
  }
  // lcd.setCursor(0, 6);
  lcd.print("P7:");
  if (car_7 <= Dist_7)
  {
    digitalWrite(carDetectLED_7, HIGH);
    lcd.print("F,");
  }
  else
  {
    total += 1;
  }
  if (car_7 > Dist_7)
  {
    digitalWrite(carDetectLED_7, LOW);
    lcd.print("E,");
    // displayParkingFee(7);
  }

  // lcd.setCursor(0, 7);
  lcd.print("P8:");
  if (car_8 <= Dist_8)
  {
    digitalWrite(carDetectLED_8, HIGH);
    lcd.print("F");
  }
  else
  {
    total += 1;
  }
  if (car_8 > Dist_8)
  {
    digitalWrite(carDetectLED_8, LOW);
    lcd.print("E");
    // displayParkingFee(8);
  }
  lcd.setCursor(0, 2);
  lcd.print("P9:");
  if (car_9 <= Dist_9)
  {
    digitalWrite(carDetectLED_9, HIGH);
    lcd.print("F,");
  }
  else
  {
    total += 1;
  }
  if (car_9 > Dist_9)
  {
    digitalWrite(carDetectLED_9, LOW);
    lcd.print("E,");
    // displayParkingFee(9);
  }
  // lcd.setCursor(0, 9);
  lcd.print("P10:");
  if (car_10 <= Dist_10)
  {
    digitalWrite(carDetectLED_10, HIGH);
    lcd.print("F");
  }
  else
  {
    total += 1;
  }
  if (car_10 > Dist_10)
  {
    digitalWrite(carDetectLED_10, LOW);
    lcd.print("E");
    // displayParkingFee(10);
  }
  // lcd.setCursor(0, 4);
  // lcd.print("E:");
  // lcd.print(total);
  // if (timer_cnt >= 50)
  {
    mySerial.print('*');
    mySerial.print(total);
    mySerial.println('#');
    timer_cnt = 0;
  }
  timer_cnt += 1;
  lcd.setCursor(0, 3);
  lcd.print("  EMPTY PARKING:");
  lcd.print(total);
  if (timer_cnt >= 50)
  {
    mySerial.print('*');
    mySerial.print(total);
    mySerial.println('#');
    timer_cnt = 0;
  }
  timer_cnt += 1;

  delay(200);
}

float sensor_1(void)
{
  digitalWrite(trig_1, HIGH);
  delayMicroseconds(10);
  digitalWrite(trig_1, LOW);
  Time_1 = pulseIn(echo_1, HIGH);
  distanceCM_1 = Time_1 * 0.034;
  return resultCM_1 = distanceCM_1 / 2;
}

float sensor_2(void)
{
  digitalWrite(trig_2, HIGH);
  delayMicroseconds(10);
  digitalWrite(trig_2, LOW);
  Time_2 = pulseIn(echo_2, HIGH);
  distanceCM_2 = Time_2 * 0.034;
  return resultCM_2 = distanceCM_2 / 2;
}

float sensor_3(void)
{
  digitalWrite(trig_3, HIGH);
  delayMicroseconds(10);
  digitalWrite(trig_3, LOW);
  Time_3 = pulseIn(echo_3, HIGH);
  distanceCM_3 = Time_3 * 0.034;
  return resultCM_3 = distanceCM_3 / 2;
}

float sensor_4(void)
{
  digitalWrite(trig_4, HIGH);
  delayMicroseconds(10);
  digitalWrite(trig_4, LOW);
  Time_4 = pulseIn(echo_4, HIGH);
  distanceCM_4 = Time_4 * 0.034;
  return resultCM_4 = distanceCM_4 / 2;
}

float sensor_5(void)
{
  digitalWrite(trig_5, HIGH);
  delayMicroseconds(10);
  digitalWrite(trig_5, LOW);
  Time_5 = pulseIn(echo_5, HIGH);
  distanceCM_5 = Time_5 * 0.034;
  return resultCM_5 = distanceCM_5 / 2;
}

float sensor_6(void)
{
  digitalWrite(trig_6, HIGH);
  delayMicroseconds(10);
  digitalWrite(trig_6, LOW);
  Time_6 = pulseIn(echo_6, HIGH);
  distanceCM_6 = Time_6 * 0.034;
  return resultCM_6 = distanceCM_6 / 2;
}

float sensor_7(void)
{
  digitalWrite(trig_7, HIGH);
  delayMicroseconds(10);
  digitalWrite(trig_7, LOW);
  Time_7 = pulseIn(echo_7, HIGH);
  distanceCM_7 = Time_7 * 0.034;
  return resultCM_7 = distanceCM_7 / 2;
}

float sensor_8(void)
{
  digitalWrite(trig_8, HIGH);
  delayMicroseconds(10);
  digitalWrite(trig_8, LOW);
  Time_8 = pulseIn(echo_8, HIGH);
  distanceCM_8 = Time_8 * 0.034;
  return resultCM_8 = distanceCM_8 / 2;
}

float sensor_9(void)
{
  digitalWrite(trig_9, HIGH);
  delayMicroseconds(10);
  digitalWrite(trig_9, LOW);
  Time_9 = pulseIn(echo_9, HIGH);
  distanceCM_9 = Time_9 * 0.034;
  return resultCM_9 = distanceCM_9 / 2;
}

float sensor_10(void)
{
  digitalWrite(trig_10, HIGH);
  delayMicroseconds(10);
  digitalWrite(trig_10, LOW);
  Time_10 = pulseIn(echo_10, HIGH);
  distanceCM_10 = Time_10 * 0.034;
  return resultCM_10 = distanceCM_10 / 2;
}

Credits

RAJESH SINHA

RAJESH SINHA

12 projects • 7 followers
Hey there! I'm Rajesh. I'm passionate about building innovative projects that solve real-world problems and make people's lives easier.

Comments