Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino Mega 2560-Based Smart Parking System with LCD, Ultrasonic Sensors, and Servo Barriers

View and Edit Project In Cirkit DesignerImage of Arduino Mega 2560-Based Smart Parking System with LCD, Ultrasonic Sensors, and Servo Barriers

Circuit Documentation

Summary

The circuit is designed to function as a parking system, utilizing a variety of sensors, displays, and actuators to manage and indicate parking space availability. The core of the system is an Arduino Mega 2560, which interfaces with ultrasonic sensors, infrared (IR) sensors, an I2C LCD display, an 8x8 LED matrix, RGB LEDs, and servo motors. The ultrasonic sensors are used to detect the presence of vehicles, while the IR sensors provide additional input for the system. The LCD display and 8x8 matrix offer visual feedback, and the RGB LEDs serve as status indicators. The servo motors are likely used to control entry and exit barriers. The system is powered by a 5V supply, with ground connections distributed throughout the components.

Component List

Wiring Details

Lcd 20x4 i2c

Arduino Mega 2560

8x8 matrix

HC-SR04 Ultrasonic Sensor

Generic Ultrasonic Sensors

IR Sensors

Servos

RGB LEDs (Wokwi compatible)

Documented Code

/*
 * Arduino Sketch for Parking System
 * This code interfaces with multiple ultrasonic sensors, IR sensors, an LCD,
 * an 8x8 matrix display, RGB LEDs, and servos to create a parking system. The
 * system detects the presence of vehicles using ultrasonic and IR sensors,
 * displays information on the LCD and 8x8 matrix, controls servos for barriers,
 * and uses RGB LEDs for status indication.
 */

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <Servo.h>

// LCD setup
LiquidCrystal_I2C lcd(0x27, 20, 4);

// Servo setup
Servo servo1;
Servo servo2;

// Pin definitions
const int irSensor1Pin = 12;
const int irSensor2Pin = 13;
const int irSensor3Pin = 10;
const int irSensor4Pin = 9;
const int trigPin1 = 40;
const int echoPin1 = 41;
const int trigPin2 = 44;
const int echoPin2 = 45;
const int trigPin3 = 31;
const int echoPin3 = 32;
const int trigPin4 = 34;
const int echoPin4 = 35;
const int trigPin5 = 38;
const int echoPin5 = 39;
const int servo1Pin = 7;
const int servo2Pin = 6;
const int matrixDIN = 14;
const int matrixCLK = 15;
const int matrixCS = 16;
const int rgbLed1R = 22;
const int rgbLed2R = 26;
const int rgbLed3R = 28;
const int rgbLed4R = 25;
const int rgbLed5R = 23;
const int rgbLed1B = 48;
const int rgbLed2G = 51;

void setup() {
  // Initialize LCD
  lcd.begin();
  lcd.backlight();
  lcd.print("Parking System");

  // Initialize servos
  servo1.attach(servo1Pin);
  servo2.attach(servo2Pin);

  // Initialize IR sensors
  pinMode(irSensor1Pin, INPUT);
  pinMode(irSensor2Pin, INPUT);
  pinMode(irSensor3Pin, INPUT);
  pinMode(irSensor4Pin, INPUT);

  // Initialize ultrasonic sensors
  pinMode(trigPin1, OUTPUT);
  pinMode(echoPin1, INPUT);
  pinMode(trigPin2, OUTPUT);
  pinMode(echoPin2, INPUT);
  pinMode(trigPin3, OUTPUT);
  pinMode(echoPin3, INPUT);
  pinMode(trigPin4, OUTPUT);
  pinMode(echoPin4, INPUT);
  pinMode(trigPin5, OUTPUT);
  pinMode(echoPin5, INPUT);

  // Initialize 8x8 matrix
  pinMode(matrixDIN, OUTPUT);
  pinMode(matrixCLK, OUTPUT);
  pinMode(matrixCS, OUTPUT);

  // Initialize RGB LEDs
  pinMode(rgbLed1R, OUTPUT);
  pinMode(rgbLed2R, OUTPUT);
  pinMode(rgbLed3R, OUTPUT);
  pinMode(rgbLed4R, OUTPUT);
  pinMode(rgbLed5R, OUTPUT);
  pinMode(rgbLed1B, OUTPUT);
  pinMode(rgbLed2G, OUTPUT);
}

void loop() {
  // Main code to run repeatedly
  // Add your logic for parking system here
}

// Function to measure distance using ultrasonic sensor
long measureDistance(int trigPin, int echoPin) {
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  long duration = pulseIn(echoPin, HIGH);
  long distance = duration * 0.034 / 2;
  return distance;
}

This code is the main sketch for the Arduino Mega 2560, which controls the parking system. It includes initializations for the LCD, servos, IR sensors, ultrasonic sensors, 8x8 matrix, and RGB LEDs. The setup() function configures the pins and initializes the components, while the loop() function is intended to contain the main logic of the parking system, which is not provided in the code snippet. The measureDistance() function is a utility to measure distance using the ultrasonic sensors.