The circuit in question is designed to create an Arduino-based parking system. It utilizes an Arduino UNO as the central processing unit, two IR sensors to detect the presence of a vehicle, a micro servo motor to control a barrier or gate, and a 16x2 I2C LCD display to provide user feedback regarding parking availability. The system operates by detecting vehicles with the IR sensors and then updating the available parking slots count displayed on the LCD. The servo motor is used to control access based on the parking availability.
#include <LiquidCrystal_I2C.h>
#include <Wire.h>
#include <Servo.h>
LiquidCrystal_I2C lcd(0x27,16,2);
Servo myservo;
int IR1 = 2;
int IR2 = 3;
int Slot = 4;
int flag1 = 0;
int flag2 = 0;
void setup() {
Serial.begin(9600);
lcd.init();
lcd.backlight();
pinMode(IR1, INPUT);
pinMode(IR2, INPUT);
myservo.attach(4);
myservo.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){
myservo.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){
myservo.write(0);
Slot = Slot+1;
}
}
if(flag1==1 && flag2==1){
delay (1000);
myservo.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
Description: This code is designed to run on an Arduino UNO and manages the parking system's logic. It initializes the LCD and servo, reads the IR sensors to detect vehicle presence, updates the available slots, and controls the servo to allow or deny access to the parking area. The LCD displays a welcome message and the number of slots left, or a message indicating that the parking is full.