This circuit is designed to manage a parking system using an Arduino UNO microcontroller. The system includes an LCD display for user interface, IR sensors for detecting car entry and exit, a servo motor for gate control, a potentiometer for adjusting the LCD contrast, a toggle switch for power control, and a resistor for current limiting. The system is powered by a 18650 Li-Ion battery.
LCD Display (16 pin)
Arduino UNO
IR Sensor
Potentiometer
Tower Pro SG90 Servo
18650 Li-Ion Battery
Resistor
Toggle Switch
#include <LiquidCrystal.h> // Include the standard LiquidCrystal library
#include <Servo.h>
Servo myservo1;
int IR1 = 2; // IR sensor for parking entry
int IR2 = 3; // IR sensor for parking exit
int Slot = 4; // Total number of parking slots
int flag1 = 0;
int flag2 = 0;
// Define the pins for the LCD (RS, E, D4, D5, D6, D7)
LiquidCrystal lcd(8, 9, 4, 5, 6, 7); // Adjust the pin numbers to match your wiring
void setup() {
lcd.begin(16, 2); // Initialize the LCD with 16 columns and 2 rows
lcd.backlight(); // Turn on the backlight
pinMode(IR1, INPUT); // Set IR1 as input
pinMode(IR2, INPUT); // Set IR2 as input
myservo1.attach(13); // Attach the servo to pin 6
myservo1.write(100); // Initial position (closed)
lcd.setCursor(0, 0);
lcd.print(" ARDUINO ");
lcd.setCursor(0, 1);
lcd.print(" PARKING SYSTEM ");
delay(2000);
lcd.clear();
}
void loop() {
// Check if car enters the parking lot (IR1 sensor triggered)
if(digitalRead(IR1) == LOW && flag1 == 0) {
if(Slot > 0) {
flag1 = 1;
if(flag2 == 0) {
myservo1.write(0); // Open the gate
Slot = Slot - 1; // Decrease the available slots
}
} else {
lcd.setCursor(0, 0);
lcd.print(" SORRY :( ");
lcd.setCursor(0, 1);
lcd.print(" Parking Full ");
delay(3000);
lcd.clear();
}
}
// Check if car leaves the parking lot (IR2 sensor triggered)
if(digitalRead(IR2) == LOW && flag2 == 0) {
flag2 = 1;
if(flag1 == 0) {
myservo1.write(0); // Open the gate
Slot = Slot + 1; // Increase the available slots
}
}
// Close the gate after both entry and exit actions are completed
if(flag1 == 1 && flag2 == 1) {
delay(1000); // Wait for a moment before closing the gate
myservo1.write(100); // Close the gate
flag1 = 0; // Reset flags
flag2 = 0;
}
// Display the available parking slots on the LCD
lcd.setCursor(0, 0);
lcd.print(" WELCOME! ");
lcd.setCursor(0, 1);
lcd.print("Slot Left: ");
lcd.print(Slot);
}
This code initializes the LCD display and servo motor, sets up the IR sensors, and manages the parking slots. The LCD displays a welcome message and the number of available slots. The servo motor controls the gate, opening it when a car enters or exits, and closing it after the action is completed. The IR sensors detect the presence of cars at the entry and exit points.