smart car parking — ESP32 simulation

An interactive ESP32 circuit simulation you can run free in your browser on Velxio, by vishwesvaran52.

Components

Sketch code

#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27, 16, 2);

int motion1 = 2;
int motion2 = 4;
int motion3 = 12;
int motion4 = 13;

void setup() {

  pinMode(motion1, INPUT);
  pinMode(motion2, INPUT);
  pinMode(motion3, INPUT);
  pinMode(motion4, INPUT);

  lcd.init();
  lcd.backlight();

  lcd.setCursor(1, 0);
  lcd.print("CAR PARKING");

  lcd.setCursor(1, 1);
  lcd.print("SYSTEM");

  delay(2000);
  lcd.clear();
}

void loop() {

  int Sensorvalue1 = digitalRead(motion1);
  int Sensorvalue2 = digitalRead(motion2);
  int Sensorvalue3 = digitalRead(motion3);
  int Sensorvalue4 = digitalRead(motion4);

  lcd.clear();

  // All slots occupied
  if (Sensorvalue1 == HIGH &&
      Sensorvalue2 == HIGH &&
      Sensorvalue3 == HIGH &&
      Sensorvalue4 == HIGH) {

    lcd.setCursor(0, 0);
    lcd.print("PARKING FULL");

    lcd.setCursor(0, 1);
    lcd.print("NO SLOT");

  }

  // Display available slots
  else {

    lcd.setCursor(0, 0);
    lcd.print("AVAILABLE:");

    lcd.setCursor(0, 1);

    if (Sensorvalue1 == LOW)
      lcd.print("1 ");

    if (Sensorvalue2 == LOW)
      lcd.print("2 ");

    if (Sensorvalue3 == LOW)
      lcd.print("3 ");

    if (Sensorvalue4 == LOW)
      lcd.print("4 ");
  }

  delay(3000);
}

More projects by vishwesvaran52