An automatic toll gate system using Arduino revolutionises traditional toll collection by eliminating manual intervention. The “automatic toll gate system project” demonstrates how simple sensors and a microcontroller can automate a real-life process like toll collection, making it an ideal project for school students and anyone just starting in the field of electronics.
In this setup, an RFID card acts as a digital payment card that carries a balance. When a vehicle arrives, the entry IR Sensor detects it, and the RFID Reader scans the card to check if there is enough balance available. If the amount is sufficient, the Arduino automatically deducts the toll, and the servo motor opens the gate. A second IR Sensor confirms when the vehicle has passed, after which the gate closes again. This automatic toll gate system project using Arduino shows how automation can make toll collection faster, easier, and completely hands-free. In this comprehensive guide, you'll learn to build an automated toll gate system that automatically detects vehicles, processes RFID card payments, deducts toll amounts, and controls gate operation.
This automatic toll gate system project using Arduino is simple, beginner-friendly, and perfect for school students as well as anyone entering the electronics field. It also relates to other similar projects, such as How to Build a Smart Toll Tax System Using Arduino Uno, RFID-Based Toll Collection System, giving learners more options to explore automated toll solutions.
Table of Contents
Components Required for Automatic Toll Gate System Project
This automatic toll gate system project using Arduino shows how simple sensors and a microcontroller can automate toll collection in a smart and efficient way. The project uses simple electronic components like IR sensors, an RFID reader, a Servo Motor and LEDs to build an automated toll gate system. Building this automatic toll gate system using Arduino requires affordable, readily available electronic components. Each component plays a specific role in creating this automated toll gate system.
| Components | Description | Qty |
| Microcontroller used to read sensors, process RFID data, and control the servo gate. | 1 | |
| Reads RFID cards and sends their unique ID to the Arduino. Used as a digital payment card scanner. | 1 | |
| RFID Tags/Cards | Stored with balance values. Used to simulate vehicle payment cards. | 3 |
| IR Sensor Modules | Detects vehicle presence at entry and exit of the toll gate. | 2 |
| Servo Motor | Acts as the automatic gate that opens and closes. | 1 |
| Red LED | Indicates access denied or gate closed. | 1 |
| Green LED | Indicates payment success or gate open | 1 |
| Jumper Wires | Used for circuit connections. | - |
| Breadboard | For connecting components without soldering. | 1 |
| 5V Power Supply / USB power | Powers the Arduino and connected components. | 1 |

Key Component Specifications for Automatic Toll Gate System
» RFID RC522: Operating frequency 13.56 MHz, read range up to 5 cm, and SPI interface communication
» IR Sensors: Detection range 2-30 cm (adjustable), digital output signal, 5V operating voltage
» SG90 Servo: Rotation range 0-180 °, operating voltage 4.8-6V, torque 1.8kg/cm
» Arduino Uno: ATmega328P processor, 14 digital I/O pins, 6 PWM outputs, 32KB flash memory
Step-by-Step Working of the Automatic Toll Gate System Project
Understanding the operational workflow of this automated toll gate system helps you grasp how Arduino coordinates multiple sensors and actuators to create a seamless toll collection experience. The automatic toll gate system project using Arduino uses an organised approach that employs different kinds of sensors and actuators. There are several ways in which the Automated Toll Collection System Works:
Complete System Workflow:
1. Vehicle Arrives - The first IR sensor detects the approaching vehicle.
2. RFID Scan - The driver taps the RFID card, and the Arduino reads its ID.
3. Card & Balance Check - The system verifies the card and checks if the balance is enough.
4. Payment Decision
- If balance is enough → toll is deducted.
- If not → access is denied.
5. Gate Opens - For successful payment, the servo opens the gate, and the green LED turns on.
6. Vehicle Passes - The second IR sensor detects the vehicle leaving.
7. Gate Closes - After the vehicle clears the exit, the gate closes, and the LEDs reset.
8. System Ready- The system waits for the next vehicle.
This workflow shows how the automatic toll gate system project uses basic sensors and an RFID-based payment method to automate the toll process. By detecting vehicles, validating cards, handling payments, and controlling the gate automatically, the setup ensures smooth, quick, and hands-free toll collection. Once the vehicle passes, the system resets and gets ready for the next one, making the entire operation efficient and easy to use.
Automatic Toll Gate Circuit Diagram and Pin Connections
The automatic toll gate circuit diagram shows the complete wiring schematic for connecting all components in this automatic toll gate system project using Arduino. The RFID Reader is connected with the SPI pins, and the IR sensors are attached to the digital input pins. The servo motor is connected to the PWM pin to control the gate's movement, and the LEDs are also connected to the digital output pins. The automatic toll gate circuit diagram shows all electrical connections between the Arduino microcontroller and peripheral components.
All components share a common 5V supply and ground line from the Arduino, except the RFID reader, which is connected to the 3.3V supply line.

Complete Pin Connection Tables for Automatic Toll Gate System
Here is the detailed breakdown of the pin connection between the different sets of sensors and the Arduino. This includes all the necessary pins for the RFID reader, IR sensors, LEDs, and the servo motor to be connected with the Arduino, in a tabular format for easy reference.
RFID RC522 Reader Pin Configuration
| RFID Pins | Arduino Pins |
| SDA | 10 |
| SCK | 13 |
| MOSI | 11 |
| MISO | 12 |
| GND | GND |
| RST | 9 |
| 3.3V | 3.3V |
RFID Reader: This reads the RFID card tapped by the driver and verifies whether the card is valid and has enough balance for toll payment.
For further guidance, you can refer to the Arduino RFID Tutorial: Complete RC522 Guide with Code & Project, which provides clear wiring diagrams and sample code for beginners. LED indicators provide clear visual feedback in the automated toll gate system, helping users understand the system status at a glance.
LED Indicator Wiring
| LEDs | Arduino Pins |
| Red LED | 6 |
| Green LED | 7 |
| Both LEDs GND | GND |
LEDs: The red and green LEDs indicate the system status, red shows that the gate is closed or access is denied, while green lights up when the gate is open, and the vehicle is allowed to pass. The IR sensors in this automatic toll gate system project provide obstacle detection capabilities.
IR Sensor Module Connections
IR Sensors | Arduino Pins |
| Entry IR OUT | 6 |
| Exit IR OUT | 7 |
| VCC | 5V |
| GND | GND |
IR Sensors: These detect the presence of a vehicle at the entry and exit points, allowing the system to know when to start and when to close the gate.
Servo Motor Gate Control
| SERVO Motor | Arduino Pins |
Signal | 5 |
| VCC | 5V |
| GND | GND |
Servo Motor: This acts as the toll gate, opening when payment is successful and closing again after the vehicle passes. The servo motor acts as the physical toll gate barrier in this automatic toll gate system project using Arduino.
A helpful guide for beginners is the tutorial How to Control Servo Motor using Arduino, which provides step-by-step instructions.
Automatic Toll Gate System Project Using Arduino Code Explained
Here is the detailed breakdown of the code. It explains important parts of the program, from reading the sensor to processing the RFID card and controlling the servo gate. The automatic toll gate system project using Arduino code is structured into logical sections that handle different aspects of the automated toll gate system.
1. Library Inclusions and Dependencies
These libraries provide essential functions for the automatic toll gate system using Arduino:
#include <SPI.h>
#include <MFRC522.h>
#include <Servo.h>This part here loads the required libraries for the project. The SPI.h library establishes communication between Arduino and the RFID reader using the SPI Protocol. The MFRC522.h library provides all the built-in functions needed to control and detect RFID cards and read their unique IDs. Finally, the Servo.h used to control the servo motor, which acted as the toll gate.
2. Pin Definitions and Hardware Mapping
#define SS_PIN 10
#define RST_PIN 9
#define IR_ENTRY 2
#define IR_EXIT 3
#define LED_RED 6
#define LED_GREEN 7
#define SERVO_PIN 5Here, the pin connection for RFID, IR sensors, LEDs, and the servo motor is defined. This section defines all hardware connections used in the automatic toll gate circuit diagram, making code maintenance easier and improving readability.
3. Object Instantiation and Global Variables
Servo gateServo;
MFRC522 rfid(SS_PIN, RST_PIN);
const int GATE_OPEN = 90;
const int GATE_CLOSED = 0;
byte Tag1[4] = {...};
byte Tag2[4] = {...};
byte Tag3[4] = {...};
int balance1 = 500;
int balance2 = 300;
int balance3 = 0;
int tollAmount = 20;
In this part, objects for the RFID module and the servo motor are created. RFID tags' IDs are stored in arrays, along with their wallet balances. Gate positions and the toll amount are also defined in this set of code. These values will be available throughout the program and can be used repeatedly during the program
4. Setup Function - System Initialisation
void setup() {
Serial.begin(9600);
SPI.begin();
rfid.PCD_Init();
pinMode(IR_ENTRY, INPUT);
pinMode(IR_EXIT, INPUT);
pinMode(LED_RED, OUTPUT);
pinMode(LED_GREEN, OUTPUT);
gateServo.attach(SERVO_PIN);
gateServo.write(GATE_CLOSED);
}The setup() Function initialises all the modules, like the SPI bus, RFID reader, servo motor, and the serial monitor. It configures the IR sensors' inputs and outputs. The gate servo motor is set to a closed position. When the system is ready, it prints a startup message and initiates the hardware for operation. These global variables store RFID card credentials and balances for the automated toll gate system.
5. Main Loop - Continuous Operation
void loop() {
digitalWrite(LED_RED, HIGH);
digitalWrite(LED_GREEN, LOW);
gateServo.write(GATE_CLOSED);
if (digitalRead(IR_ENTRY)) {
Serial.println("\nCar at entry. Waiting for RFID...\n");
while (digitalRead(IR_ENTRY) == HIGH) {
if (!rfid.PICC_IsNewCardPresent() || !rfid.PICC_ReadCardSerial()) {
delay(100);
continue;
}
Serial.print("RFID Tag Detected: ");
printUID(rfid.uid.uidByte);
Serial.println();
bool is1 = uidEquals(rfid.uid.uidByte, Tag1);
bool is2 = uidEquals(rfid.uid.uidByte, Tag2);
bool is3 = uidEquals(rfid.uid.uidByte, Tag3);
if (is1) {
processCard(balance1, 1);
} else if (is2) {
processCard(balance2, 2);
} else if (is3) {
processCard(balance3, 3);
} else {
Serial.println("Unknown Card -- Access Denied");
denyAccess();
}
waitForCardRemoval();
rfid.PICC_HaltA();
rfid.PCD_StopCrypto1();
delay(200);
}
}
}The loop() function resets the system by turning on the red LED, turning off the Green LED. Initially, the gate is closed, and then it checks for any entry in the IR sensor, and if a vehicle is detected, then the system starts to read the RFID card. When a card is scanned, the UID of the card is obtained and compared with the stored cards' IDs. If the card ID is matched and has enough balance, only then is the toll payment processed, and the gate is opened. If there is a mismatch between the card ID and the stored ID then the gate does not open. The setup function initialises all hardware components required for the automatic toll gate system project using Arduino.
Serial Monitor Output - Automatic Toll Gate System Testing
The serial monitor provides real-time feedback for debugging and monitoring the automatic toll gate system project. These logs help verify that the system is functioning correctly and make debugging easier during development.
Below is the sample serial output format:



The first output shows the complete flow of a successful vehicle entry. When the IR sensor detects a car and then the system scans the RFID tag and verifies the card as authorised. After confirming the balance and deducting the toll amount, the Arduino opens the servo-controlled gate, allowing the vehicle to pass and then closes the gate. Finally, the system resets and waits for the next vehicle.


In the insufficient balance scenario, the system reads the RFID card, but after checking the stored balance, it finds that the amount is not enough to pay the toll. The Arduino then denies access and displays a warning message in the Serial Monitor.
Real-World Applications of Automatic Toll Gate Systems
The automated toll gate system technology has numerous practical applications beyond basic toll collection:
» Highway Toll Plazas: Automated toll collection reduces traffic congestion and eliminates manual cash handling, improving throughput on busy roads.
» Parking Facilities: Shopping malls, airports, and office complexes use RFID-based automated entry/exit systems for efficient parking management.
» Residential Complexes: Gated communities implement RFID access control for resident vehicle identification and security management.
» Industrial Facilities: Warehouses and manufacturing plants use automated gates for vehicle tracking and access authorisation.
» Educational Institutions: Schools and universities deploy RFID systems for campus vehicle access and parking management.
» Event Venues: Stadiums and concert halls utilise automated gates for quick, contactless ticket validation and entry management.
Troubleshooting Common Issues in the Automatic Toll Gate System
| Problem | Possible Causes | Solutions |
|---|---|---|
| RFID reader not detecting cards | • Wrong voltage (using 5V instead of 3.3V) • Loose SPI connections • Incorrect library version | • Verify 3.3V power connection • Check all SPI wires (MOSI, MISO, SCK, SS) • Update MFRC522 library to latest version • Test card detection range (max 5cm) |
| Servo motor not moving | • Insufficient power supply • Wrong pin connection • Servo.h library not included | • Use external 5V power for servo (min 500mA) • Verify signal pin connected to digital pin 5 • Include Servo.h at code beginning • Test servo independently with sweep code |
| IR sensors always triggered | • Incorrect sensitivity adjustment • Ambient light interference • Sensor positioned too close | • Adjust potentiometer on IR module • Shield sensors from direct sunlight • Position sensors 10-15cm from detection point • Add delay in code to debounce signals |
| Gate closes before vehicle passes | • Exit IR sensor not working • Insufficient delay in code • Wrong sensor positioning | • Test exit sensor independently • Increase delay after gate opens (2-3 seconds) • Position exit sensor beyond gate barrier • Add while loop to wait for vehicle passage |
| Balance not updating correctly | • Variable not passed by reference • Code logic error • Balance reset on power cycle | • Use & operator in function parameters • Verify deduction logic in processCard() • Store balances in EEPROM for persistence • Add serial debug prints to track changes |
| Multiple cards same UID | • Using default UID from examples • Cards not properly initialized • Clone cards from same batch | • Read actual UID using RFID dump code • Use unique cards for testing • Update Tag arrays with real UIDs • Consider using card's memory blocks |
Advanced Features for Your Automatic Toll Gate System Project
Enhance your automatic toll gate system project using Arduino with these advanced modifications:
1. IoT Integration and Cloud Connectivity
2. Payment System Enhancements
3. Advanced Sensor Integration
4. User Interface Improvements
5. Security and Safety Features
Reference projects
- RFID-Based Attendance System Using Arduino - Complete Project Guide
- How to Make an RFID Door Lock System using Arduino
GitHub Repository and Source Files
Access the complete source code, circuit diagrams, and documentation for this automatic toll gate system project using Arduino.
RFID-Based Projects using EM18 RFID Reader
Previously, we have used RFID to build many interesting projects. If you want to know more about those topics, links are given below.
Fingerprint-based Car Ignition System using Arduino and RFID
In this Fingerprint-Based Car Ignition System, we are using Arduino with an R305 Fingerprint sensor and an EM18 RFID reader.
IoT-based Event Management System using RFID and ThingSpeak
Build an RFID-based IoT-enabled event Management System that not only monitors the entry log but, with the help of IoT technology but can also send the Log and Entry data directly to a dedicated server that can handle all the authentication, authorisation, and management, making the whole process seamless.
How to Connect RFID with STM32 Microcontroller
Build an RFID-based IoT-enabled event Management System that not only monitors the entry log, but with the help of IoT technology but can also send the Log and Entry data directly to a dedicated server that can handle all the authentication, authorisation, and management, making the whole process seamless.
Complete Project Code
#include <SPI.h>
#include <MFRC522.h>
#include <Servo.h>
// RFID Pins
#define SS_PIN 10
#define RST_PIN 9
// IR sensors
#define IR_ENTRY 2
#define IR_EXIT 3
// LEDs
#define LED_RED 6
#define LED_GREEN 7
// Servo
#define SERVO_PIN 5
Servo gateServo;
MFRC522 rfid(SS_PIN, RST_PIN);
// Servo positions
const int GATE_OPEN = 90;
const int GATE_CLOSED = 0;
// ---- STORED RFID CARDS (4-byte UIDs) ----
byte Tag1[4] = {0x02, 0xC9, 0x8B, 0x41};
byte Tag2[4] = {0x09, 0xD6, 0x8B, 0x5A};
byte Tag3[4] = {0x23, 0xD8, 0x50, 0xD0};
// ---- BALANCES ----
int balance1 = 500;
int balance2 = 300;
int balance3 = 0;
int tollAmount = 20;
void setup() {
Serial.begin(9600);
SPI.begin();
rfid.PCD_Init();
pinMode(IR_ENTRY, INPUT);
pinMode(IR_EXIT, INPUT);
pinMode(LED_RED, OUTPUT);
pinMode(LED_GREEN, OUTPUT);
gateServo.attach(SERVO_PIN);
gateServo.write(GATE_CLOSED);
digitalWrite(LED_RED, HIGH);
digitalWrite(LED_GREEN, LOW);
Serial.println("Toll System Initialized...");
}
bool uidEquals(byte *a, byte *b) {
for (byte i = 0; i < 4; i++)
if (a[i] != b[i]) return false;
return true;
}
void printUID(byte *uid) {
for (byte i = 0; i < 4; i++) {
if (uid[i] < 0x10) Serial.print("0");
Serial.print(uid[i], HEX);
if (i < 3) Serial.print(" ");
}
}
void waitForCardRemoval() {
while (rfid.PICC_IsNewCardPresent() && rfid.PICC_ReadCardSerial()) {
delay(50);
}
}
void loop() {
digitalWrite(LED_RED, HIGH);
digitalWrite(LED_GREEN, LOW);
gateServo.write(GATE_CLOSED);
if (digitalRead(IR_ENTRY)) {
Serial.println("\nCar at entry. Waiting for RFID...\n");
while (digitalRead(IR_ENTRY) == HIGH) {
if (!rfid.PICC_IsNewCardPresent() || !rfid.PICC_ReadCardSerial()) {
delay(100);
continue;
}
Serial.print("RFID Tag Detected: ");
printUID(rfid.uid.uidByte);
Serial.println();
bool is1 = uidEquals(rfid.uid.uidByte, Tag1);
bool is2 = uidEquals(rfid.uid.uidByte, Tag2);
bool is3 = uidEquals(rfid.uid.uidByte, Tag3);
// Process each card
if (is1) {
processCard(balance1, 1);
} else if (is2) {
processCard(balance2, 2);
} else if (is3) {
processCard(balance3, 3);
} else {
Serial.println("Unknown Card -- Access Denied");
denyAccess();
}
// Cleanup and wait for removal
waitForCardRemoval();
rfid.PICC_HaltA();
rfid.PCD_StopCrypto1();
delay(200);
}
}
}
void processCard(int &balance, int cardNumber) {
if (balance >= tollAmount) {
balance -= tollAmount;
Serial.print("New Balance: Rs ");
Serial.println(balance);
openGateAndWaitExit();
}
else {
Serial.println("Insufficient Balance -- Access Denied");
denyAccess();
}
}
void denyAccess() {
for (int i = 0; i < 3; i++) {
digitalWrite(LED_RED, LOW);
delay(150);
digitalWrite(LED_RED, HIGH);
delay(150);
}
}
void openGateAndWaitExit() {
digitalWrite(LED_RED, LOW);
digitalWrite(LED_GREEN, HIGH);
gateServo.write(GATE_OPEN);
Serial.println("Gate Opened...\n");
// Wait for car to reach exit sensor
while (digitalRead(IR_EXIT) == LOW) delay(50);
// Wait for car to clear exit sensor
while (digitalRead(IR_EXIT) == HIGH) delay(50);
delay(500);
// Close gate
gateServo.write(GATE_CLOSED);
digitalWrite(LED_GREEN, LOW);
digitalWrite(LED_RED, HIGH);
Serial.println("Gate Closed.");
}


