Arduino UNO Smart Parking System with IR Sensors and Servo Motors
View and Edit Project In Cirkit Designer
Circuit Documentation
Summary
This circuit is designed to manage a smart parking system. It uses an Arduino UNO microcontroller to control two servos and an LCD screen, and to read inputs from two IR sensors. The servos control the entry and exit gates, while the LCD screen displays the status of the parking lot. The IR sensors detect the presence of vehicles at the entry and exit points.
Component List
IR Sensor
- Pins: out, gnd, vcc
- Description: Detects the presence of a vehicle.
- Purpose in Circuit: Provides input signals to the Arduino to indicate vehicle presence.
Tower Pro SG90 Servo
- Pins: Signal, +5V, GND
- Description: A small servo motor.
- Purpose in Circuit: Controls the entry and exit gates.
LCD Screen 16x2 I2C
- Pins: SCL, SDA, VCC, GND
- Description: A 16x2 character LCD with I2C interface.
- Purpose in Circuit: Displays the status of the parking lot.
Arduino UNO
- Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0, A1, A2, A3, A4, A5, SCL, SDA, AREF, D13, D12, D11, D10, D9, D8, D7, D6, D5, D4, D3, D2, D1, D0
- Description: A microcontroller board based on the ATmega328P.
- Purpose in Circuit: Central control unit for the smart parking system.
2x 18650 Battery
- Pins: vcc, gnd
- Description: A pair of 18650 lithium-ion batteries.
- Purpose in Circuit: Provides power to the Arduino UNO.
Wiring Details
IR Sensor 1
- out connected to Arduino UNO D12
- gnd connected to Arduino UNO GND
- vcc connected to Arduino UNO 5V
IR Sensor 2
- out connected to Arduino UNO D2
- gnd connected to Arduino UNO GND
- vcc connected to Arduino UNO 5V
Tower Pro SG90 Servo 1
- Signal connected to Arduino UNO D11
- +5V connected to Arduino UNO 5V
- GND connected to Arduino UNO GND
Tower Pro SG90 Servo 2
- Signal connected to Arduino UNO D5
- +5V connected to Arduino UNO 5V
- GND connected to Arduino UNO GND
LCD Screen 16x2 I2C
- SCL connected to Arduino UNO A5
- SDA connected to Arduino UNO A4
- VCC connected to Arduino UNO 5V
- GND connected to Arduino UNO GND
Arduino UNO
- 5V connected to IR Sensor 1 vcc, IR Sensor 2 vcc, Tower Pro SG90 Servo 1 +5V, Tower Pro SG90 Servo 2 +5V, LCD Screen 16x2 I2C VCC
- GND connected to IR Sensor 1 gnd, IR Sensor 2 gnd, Tower Pro SG90 Servo 1 GND, Tower Pro SG90 Servo 2 GND, LCD Screen 16x2 I2C GND
- Vin connected to 2x 18650 Battery vcc
- GND connected to 2x 18650 Battery gnd
Documented Code
Arduino UNO Code
#include <Servo.h> // Thư viện cho Servo
Servo servoIN; // khai báo servo lối vào
Servo servoOUT; // khai báo servo lối ra
#include <LiquidCrystal_I2C.h> // Thư viện cho LCD I2C
#include <Wire.h>
LiquidCrystal_I2C lcd(0x27,16,2); // Khai báo địa chỉ cho LCD
int A;
int B;
int cambien1 = 12; // chân cảm biến lối vào tại D12
int cambien2 = 2; // chân cảm biến lối ra tại D2
int Total = 5; // Tổng chỗ trống
int Lots;
void setup() {
servoIN.attach(11); // servo lối vào ở D11
servoIN.write(0);
servoOUT.attach(5); // servo lối ra ở D5
servoOUT.write(0);
pinMode(cambien1,INPUT); //Khai báo cho cảm biến 1
pinMode(cambien2,INPUT); //Khai báo cho cảm biến 2
lcd.init(); //Khởi chạy LCD
lcd.backlight(); // Bật đèn nền
lcd.clear();// Xóa màn hình hiện có
lcd.setCursor(2, 0); // Đặt con trỏ tại cột 2, hàng 0
lcd.print("Smart Parking");
lcd.setCursor(5,1); // Đặt con trỏ tại cột 5, hàng 1
lcd.print("System");
delay(1500);
lcd.clear();
Lots = Total;
}
void loop() {
A = digitalRead(cambien1);
B = digitalRead(cambien2);
if (A == LOW && Lots > 0) {
delay(100);
servoIN.write(90);
if (digitalRead(cambien1) == HIGH) {
lcd.clear();
lcd.setCursor(4, 0);
lcd.print("Welcome!");
servoIN.write(90);
delay(1000);
lcd.clear();
servoIN.write(0);
Lots = Lots - 1;
}
}
if (A == LOW && Lots == 0){
lcd.clear();
lcd.setCursor(2,0);
lcd.print("Sorry no lot");
lcd.setCursor(3,1);
lcd.print("available!");
delay (1200);
lcd.clear();
}
if (B == LOW && Lots < 5) {
delay(100);
servoOUT.write(90);
if (digitalRead(cambien2) == HIGH) {
lcd.clear();
lcd.setCursor(1, 0);
lcd.print("See you again!");
servoOUT.write(90);
delay(1000);
lcd.clear();
servoOUT.write(0);
Lots = Lots + 1;
}
}
lcd.setCursor(0,0);
lcd.print("Total Lots: "); // Tổng chỗ trống
lcd.print(Total);
lcd.setCursor(0,1);
lcd.print("Lots Left: "); // Chỗ trống còn lại
lcd.print(Lots);
}
LCD Screen 16x2 I2C Code
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
}
This documentation provides a comprehensive overview of the smart parking system circuit, including the components used, their wiring details, and the code running on the microcontrollers.