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.
Add kit to cartOption 2 — Individual components
₹1,312The full parts list is ₹1,312 for all 8 items. Add them all at once, or pick single items from the list below.
- Arduino Uno R3 Compatible Board with USB CableCB-UNO-R3₹499Add to cart
- IR Obstacle Avoidance Sensor ModuleCS-IR-OBST₹59Add to cart
- SG90 Micro Servo Motor 9gCMO-SG90₹89Add to cart
- 0.96 inch OLED Display 128×64 I2C (SSD1306)CD-OLED-096₹199Add to cart
- LED Assortment Pack 100 Pieces (5 Colours)CA-LED-PACK₹79Add to cart
- Resistor Assortment Pack 600 PiecesCA-RES-PACK₹149Add to cart
- 830 Point Solderless BreadboardCA-BB-830₹89Add to cart
- Jumper Wire Set 120 Pieces (M-M, M-F, F-F)CA-JUMPER-120₹149Add to cart
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.