← All Projects
Smart Parking With OLED
35 viewsApril 3, 2026
Circuit Connections
| Component | Pin | Pin | Component | |
|---|---|---|---|---|
| OLED | SDA | → | A4 | ARDUINO UNO |
| OLED | SCL | → | A5 | ARDUINO UNO |
| OLED | VCC | → | 5V | ARDUINO UNO |
| OLED | GND | → | GND | ARDUINO UNO |
| SERVO | RED | → | 5V | ARDUINO UNO |
| SERVO | BROWN | → | GND | ARDUINO UNO |
| SERVO | YELLOW | → | Pin 9 | ARDUINO UNO |
| IR SENSOR 1 | OUT | → | Pin 2 | ARDUINO UNO |
| IR SENSOR 2 | OUT | → | Pin 3 | ARDUINO UNO |
| IR SENSOR 3 | OUT | → | Pin 4 | ARDUINO UNO |
| IR SENSOR 1, 2, 3 | GND | → | GND | ARDUINO UNO |
| IR SENSOR 1, 2, 3 | VCC | → | 5V | ARDUINO UNO |
arduino— code.ino
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Servo.h>
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
Servo gate;
const int irEntry = 2;
const int irSlot1 = 3;
const int irSlot2 = 4;
void setup() {
Serial.begin(9600);
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
Serial.println(F("OLED Missing"));
for(;;);
}
// Initial Splash Screen
display.clearDisplay();
display.setTextSize(2); // Larger text for branding
display.setTextColor(WHITE);
display.setCursor(5, 25);
display.println("@itzbandhan");
display.display();
delay(3000);
gate.attach(9);
gate.write(0); // Close gate
pinMode(irEntry, INPUT);
pinMode(irSlot1, INPUT);
pinMode(irSlot2, INPUT);
}
void loop() {
// Read Sensors (LOW = Car Detected)
bool s1Full = (digitalRead(irSlot1) == LOW);
bool s2Full = (digitalRead(irSlot2) == LOW);
bool carAtEntry = (digitalRead(irEntry) == LOW);
// Calculate availability
int occupied = 0;
if (s1Full) occupied++;
if (s2Full) occupied++;
int available = 2 - occupied;
// 1. Check for Entry Request
if (carAtEntry) {
display.clearDisplay();
display.setCursor(0, 20);
display.setTextSize(1);
if (available > 0) {
display.println("WELCOME! GATE OPENING");
display.display();
gate.write(90); // Open
delay(3500); // Time for car to pass
gate.write(0); // Close
} else {
display.setTextSize(2);
display.println("SORRY...");
display.println("LOT FULL");
display.display();
delay(2000);
}
}
// 2. Main Status Display
display.clearDisplay();
if (available == 0) {
// BIG FULL MESSAGE
display.setCursor(0, 10);
display.setTextSize(2);
display.println(" PARKING ");
display.println(" FULL! ");
display.setTextSize(1);
display.setCursor(15, 50);
display.println("NO SPACE AVAILABLE");
} else {
// NORMAL STATUS
display.setTextSize(1);
display.setCursor(0, 0);
display.println("--- SMART PARKING ---");
display.drawLine(0, 10, 128, 10, WHITE);
display.setCursor(0, 25);
display.print("SLOT 1: ");
display.println(s1Full ? "OCCUPIED" : "FREE");
display.setCursor(0, 40);
display.print("SLOT 2: ");
display.println(s2Full ? "OCCUPIED" : "FREE");
display.setCursor(0, 55);
display.print("SPACES LEFT: ");
display.print(available);
}
display.display();
delay(300); // Quick refresh for sensors
}