Arduino UNO Based Car Parking System with IR Sensors and Servo-Controlled Gate
View and Edit Project In Cirkit Designer
Circuit Documentation
Summary of the Circuit
This circuit is designed to create an Arduino-based car parking system. It utilizes an Arduino UNO as the central microcontroller to manage inputs from infrared (IR) sensors and control an LCD screen and a servo motor. The IR sensors detect the presence of a car, the LCD screen displays the parking system status and available slots, and the servo motor acts as a barrier that opens or closes based on the parking availability.
Component List
Arduino UNO
- Description: A microcontroller board based on the ATmega328P.
- Purpose: Acts as the central processing unit of the parking system, reading sensor inputs, controlling the servo motor, and updating the display on the LCD screen.
IR Sensors
- Description: Infrared sensors used for detecting the presence of objects.
- Purpose: To detect the presence of cars entering or leaving the parking area.
LCD Screen 16x2 I2C
- Description: A 16x2 character LCD display with an I2C interface.
- Purpose: To display the status of the parking system and the number of available slots.
Servo
- Description: A rotary actuator or motor that allows for precise control of angular position.
- Purpose: To act as a barrier that opens or closes based on parking slot availability.
Wiring Details
Arduino UNO
- 5V: Connected to the VCC pins of both IR sensors, the LCD screen, and the Servo.
- GND: Connected to the GND pins of both IR sensors, the LCD screen, and the Servo.
- D2: Connected to the 'out' pin of one IR sensor.
- D3: Connected to the 'pulse' pin of the Servo.
- D4: Connected to the 'out' pin of the other IR sensor.
- SCL: Connected to the SCL pin of the LCD screen.
- SDA: Connected to the SDA pin of the LCD screen.
IR Sensors
- VCC: Connected to the 5V output from the Arduino UNO.
- GND: Connected to the ground (GND) on the Arduino UNO.
- Out: One sensor's output is connected to D2 on the Arduino UNO, and the other sensor's output is connected to D4.
LCD Screen 16x2 I2C
- VCC: Connected to the 5V output from the Arduino UNO.
- GND: Connected to the ground (GND) on the Arduino UNO.
- SCL: Connected to the SCL pin on the Arduino UNO.
- SDA: Connected to the SDA pin on the Arduino UNO.
Servo
- VCC: Connected to the 5V output from the Arduino UNO.
- GND: Connected to the ground (GND) on the Arduino UNO.
- Pulse: Connected to D3 on the Arduino UNO.
Documented Code
Arduino UNO Code
// Viral Science www.viralsciencecreativity.com www.youtube.com/c/viralscience
// Arduino Car Parking System
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x3F,16,2); //Change the HEX address
#include <Servo.h>
Servo myservo1;
int IR1 = 2;
int IR2 = 4;
int Slot = 4; //Enter Total number of parking Slots
int flag1 = 0;
int flag2 = 0;
void setup() {
lcd.begin();
lcd.backlight();
pinMode(IR1, INPUT);
pinMode(IR2, INPUT);
myservo1.attach(3);
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);
}
Filename: sketch.ino
(Note: The second microcontroller instance does not have associated functional code and is therefore not included in this documentation.)