Finding an empty parking space can be frustrating. In this project I built a mini smart parking system with an Arduino Uno that monitors three parking slots and controls an automatic entrance gate.
Each slot has its own IR obstacle sensor. When a car parks, the sensor detects it and the Arduino updates the slot status on a 128×64 I2C OLED, showing which spaces are occupied and how many are free. An SG90 servo acts as the entrance gate: it stays open while at least one slot is free and closes when the parking is full.
This page covers how it works and the wiring. The complete Arduino code, a section-by-section code walkthrough, a troubleshooting table and FAQs are in the full tutorial on my website: Arduino Smart Parking System – full tutorial and code on Electronixity.

Demo video
How it works

The Arduino keeps checking the three IR sensors:
- Detecting a car: each IR module shines infrared light. When a car sits in front of it, light reflects back and the module's digital output changes (on most modules it goes LOW). The potentiometer sets the detection threshold.
- Checking the slots: sensor 1 watches slot 1, sensor 2 watches slot 2 and sensor 3 watches slot 3.
- Counting free spaces: free slots = 3 − occupied slots.
- Updating the OLED: the screen shows each slot as OCCUPIED or EMPTY plus the number of free spaces.
- Controlling the gate: if at least one slot is free, the servo opens the gate (90°). When all three are occupied, it closes (0°).
Gate logic: 0, 1 or 2 cars parked → gate open. 3 cars parked → gate closed. As soon as one car leaves, it opens again.

Circuit diagram and wiring

Disconnect the Arduino from USB before wiring.
IR sensors → Arduino Uno
- Slot 1 OUT → D2, Slot 2 OUT → D3, Slot 3 OUT → D4
- All VCC → 5V, all GND → GND

OLED → Arduino Uno
- VCC → 5V (if your module supports it), GND → GND
- SDA → A4, SCL → A5

SG90 servo
- Signal (orange/yellow) → D9
- Red → external regulated 5V supply
- Brown/black → external supply GND and Arduino GND

Power tip: don't run the servo from the Uno's 5V pin. Use a separate regulated 5V supply (like an MB102 breadboard power module) and connect its ground to the Arduino GND. Don't connect the external supply's positive output to the Arduino 5V pin while the Uno is powered over USB.
Libraries
Install Adafruit SSD1306 and Adafruit GFX Library from the Arduino IDE Library Manager. The Servo library is normally included with the IDE. Reading the IR sensors needs no extra library.
Code
The complete sketch, with an explanation of how it reads the sensors, counts free slots, controls the gate and updates the OLED, is here:
👉 Get the complete Arduino Smart Parking code on Electronixity
The tutorial also shows the two settings you may need to change: the sensor logic (LOW vs HIGH when a car is detected) and the OLED I2C address (0x3C or 0x3D).
Testing
- After uploading, the OLED should show all three slots as EMPTY with FREE SLOTS: 3, and the gate should open.
- Place a toy car in front of sensor 1: SLOT 1 becomes OCCUPIED and FREE SLOTS drops to 2. The gate stays open.
- Repeat with slots 2 and 3. When all three are occupied, FREE SLOTS shows 0 and the servo closes the gate.
- Remove any one car. The free count goes back to 1 and the gate opens again.
- Open the Serial Monitor at 9600 baud to see each slot's status and the gate state.
If a sensor doesn't detect the car reliably, slowly turn its potentiometer while watching the module's indicator LED. Car colour and surface finish affect how much IR light reflects back.
Something not right? Blank OLED, a slot stuck on OCCUPIED, a servo that won't move or moves the wrong way, or an Arduino that resets are all covered in the troubleshooting table of the full tutorial on Electronixity.
This is a demonstration model, not a complete access-control system. A real parking gate needs separate entry/exit detection and gate safety logic.