An IR sensor spots the car, a servo lifts the boom and the OLED shows whether a bay is free. A complete gate in one afternoon, and the cleanest introduction we know to state handling.
What it does
The gate opens on detection, holds long enough for the vehicle to clear, then closes — with the slot count and the red and green indicators updating as it goes.
Circuit connections
| Connection | Arduino pin |
|---|---|
| IR sensor OUT | D2 |
| Red LED (via 220R) | D3 |
| Green LED (via 220R) | D4 |
| Servo signal | D9 |
| OLED SDA / SCL | A4 / A5 |
| Power rails | 5V + GND |
Bench note: Give the SG90 its own 5V feed if the boom arm is longer than a lolly stick. Servo stall current resets the Uno, and it looks exactly like a code bug.
Libraries used
Servo.hWire.hAdafruit_GFX.hAdafruit_SSD1306.hGet the parts
Two ways to build this, and you can choose either. Take the complete kit in one box, or buy only the individual components you are missing. Both use the normal shop cart.
Option 1 — Complete kit
₹2,499eARgle Arduino Fundamentals Kit (20-Day Programme) — everything needed, boxed, with the quick-start card and reference sketches.
Enquire to orderOption 2 — Individual components
₹809Live prices from our partner Robolark: ₹809 for 6 of 9 parts in stock. Add them all at once, or pick single items from the list below.
Add all 6 components✓ Added to your Parts Box. View Parts Box
- Uno R3-Microcontroller (ATmega328p)-Arduino CompatibleR-0007₹380Add to Parts Box
- IR Sensor/Infrared Proximity SensorR-0400₹32Add to Parts Box
- Servo Motor-SG90 MicroR-0567₹97Add to Parts Box
- Oled Display - 4 pin (0.96 Inch)R-0036₹200Add to Parts Box
- Red LED-5mm (Pack of 5)R-0535₹5Out of stock
- Green LED - 5mm (Pack of 5)R-0364₹5Out of stock
- Resistor Box- AssortmentR-0541₹80Add to Parts Box
- MB-102 Solderless Breadboard - 830 Tie PointsR-0204₹69Out of stock
- Jumper Wires - Male to Male × 2R-0457₹20Add to Parts Box
Already own the board or the display? Skip them — the sketches do not care where the parts came from.
Source code
Every sketch on this page is open source. Clone it, change it, break it, tell us what you learned.
Want to be taught this, not just handed the code?
We run this as a mentor-led session for schools, colleges and individual learners, online or at our centre. Tell us what you want to build.