0% found this document useful (0 votes)
13 views3 pages

Parking Without Keypad

The document contains a code for a smart parking system using an Arduino, which integrates an LCD display, servo motors, and infrared sensors. It measures distance to detect parking space availability and uses a buzzer for alerts. The system updates the LCD with parking slot status and controls entry and exit mechanisms based on sensor readings.

Uploaded by

asdf
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views3 pages

Parking Without Keypad

The document contains a code for a smart parking system using an Arduino, which integrates an LCD display, servo motors, and infrared sensors. It measures distance to detect parking space availability and uses a buzzer for alerts. The system updates the LCD with parking slot status and controls entry and exit mechanisms based on sensor readings.

Uploaded by

asdf
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

//parking without keypad

#include <LiquidCrystal_I2C.h>
#include <Servo.h> //Library for the servo motor

Servo Entry, Exit; //Object of type servo

#define IR_exit 7 //Define pins


#define IR_Slot3 8
#define IR_Slot2 5
#define IR_Slot1 6
#define IR_entry 4
#define buzzer 11
#define echo A1
#define trig A0

const int pos = 0; //Initial Position of servo motor

//initialize the library with the numbers of the interface pins


LiquidCrystal_I2C lcd(0x27,16,2);

float getDistance() {
digitalWrite(trig, LOW);
delayMicroseconds(2);
digitalWrite(trig, HIGH);
delayMicroseconds(10);
digitalWrite(trig, LOW);

float distance = pulseIn(echo, HIGH) / 58;


delay(10);
return distance;
}

void adaptiveBeep(float distance) {


if (distance > 0 && distance < 10) {
tone(buzzer, 500);
}
else {
noTone(buzzer);
}
}

void setup() {
Serial.begin(9600);
Entry.attach(10); //Entry on 12 pin
Exit.attach(12); //Exit on 13 pin

Entry.write(pos+90); //Initial position at 0 for both motors


Exit.write(pos);

pinMode(IR_Slot1, INPUT); //Pin modes


pinMode(IR_Slot2, INPUT);
pinMode(IR_Slot3, INPUT);
pinMode(IR_entry, INPUT);
pinMode(IR_exit, INPUT);
pinMode(trig, OUTPUT);
pinMode(buzzer, OUTPUT);
lcd.init(); //Initialize the 16x2 LCD
lcd.backlight();

//Print a message to the LCD


lcd.print("Smart Parking");
lcd.setCursor(0,1); //Set cursor to column 1, row 2
lcd.print("System");
delay(2000);
lcd.clear(); //Clear the lcd screen
lcd.setCursor(0, 0); //Set cursor to column 1, row 0
lcd.print("S1 = A");
lcd.setCursor(0, 1); //Set cursor to column 1, row 1
lcd.print("S2 = A");
lcd.setCursor(8, 0); //Set cursor to column 8, row 0
lcd.print("S3 = A");
// lcd.setCursor(8, 1); //Set cursor to column 8, row 1
// lcd.print("d = 0");
delay(2000);
}

void loop()
{
int distance = getDistance();
// lcd.setCursor(8, 1);
// lcd.print("d = ");
// lcd.setCursor(12, 1);
// lcd.print(" ");
// lcd.setCursor(12, 1);
// lcd.print(distance);
//Serial.println(distance);
adaptiveBeep(distance);

Serial.print(digitalRead(IR_entry));
Serial.print(" ");
Serial.print(digitalRead(IR_Slot1));
Serial.print(digitalRead(IR_Slot2));
Serial.println(digitalRead(IR_Slot3));

if(digitalRead(IR_Slot1)==HIGH)
{
lcd.setCursor(0, 0);

lcd.print("S1 = NA");
}
else
{
lcd.setCursor(0, 0);
lcd.print("S1 = A ");
}

if(digitalRead(IR_Slot2)==HIGH)
{
lcd.setCursor(0, 1);

lcd.print("S2 = NA");
}
else
{
lcd.setCursor(0, 1);

lcd.print("S2 = A ");
}

if(digitalRead(IR_Slot3)==HIGH)
{
lcd.setCursor(8, 0);

lcd.print("S3 = NA");
}
else
{
lcd.setCursor(8, 0);

lcd.print("S3 = A ");
}

if(digitalRead(IR_entry)==LOW &&
(digitalRead(IR_Slot1)==HIGH ||
digitalRead(IR_Slot2)==HIGH ||
digitalRead(IR_Slot3)==HIGH))
{
Entry.write(pos);
}
else
{
Entry.write(pos+90);
}

if(digitalRead(IR_exit)==HIGH)
{
Exit.write(pos);
}
else
{
Exit.write(pos+90);
}

You might also like