RFID-Based Smart Traffic Control System Using Arduino Mega

 

This project is an intelligent RFID-enabled traffic management system built using the powerful Arduino Mega 2560. It integrates multiple MFRC522 modules and traffic light units to create a smart intersection control system capable of vehicle identification and priority-based signal control.

The system is designed to reduce congestion and provide emergency vehicle priority at busy road intersections.


 Components Used

  • Arduino Mega 2560

  • MFRC522 (Multiple Units)

  • Traffic Light LED Modules (Red, Yellow, Green)

  • Breadboard

  • Resistors

  • Jumper Wires

  • Power Supply


 How the System Works

1️⃣ RFID Vehicle Detection

Each lane is equipped with an MFRC522 RFID reader.

  • Vehicles with authorized RFID tags are detected.

  • The system identifies vehicle type (normal or emergency).

2️⃣ Smart Signal Control

The Arduino Mega processes RFID inputs and:

  • Gives priority to emergency vehicles (ambulance, fire service).

  • Adjusts green signal timing dynamically.

  • Maintains coordinated traffic flow at the intersection.

3️⃣ Multi-Lane Management

Four traffic light modules represent a 4-way junction.
The system ensures:

  • Only one direction gets green at a time.

  • Safe transition using yellow signal delay.

  • Reduced waiting time using intelligent switching logic.


 Key Features

✔ RFID-based vehicle identification
✔ Emergency vehicle priority system
✔ Dynamic signal timing control
✔ Multi-lane intersection management
✔ Scalable smart city prototype
✔ Suitable for competitions and exhibitions

Coding:

/*
 * RFID-Based Smart Traffic Control System Using Arduino Mega
 *
 * This Arduino sketch controls a smart traffic light system using RFID readers.
 * Each traffic light is controlled by the Arduino Mega, and RFID readers are
 * used to detect vehicles. The system changes the traffic lights based on the
 * presence of vehicles detected by the RFID readers.
 */

#include <SPI.h>
#include <MFRC522.h>

// Define RFID reader pins
#define RST_PIN         49
#define SS_PIN_1        7
#define SS_PIN_2        8
#define SS_PIN_3        9
#define SS_PIN_4        10

// Define traffic light pins
#define RED_LIGHT_1     22
#define YELLOW_LIGHT_1  23
#define GREEN_LIGHT_1   24
#define RED_LIGHT_2     25
#define YELLOW_LIGHT_2  26
#define GREEN_LIGHT_2   27
#define RED_LIGHT_3     28
#define YELLOW_LIGHT_3  29
#define GREEN_LIGHT_3   30
#define RED_LIGHT_4     31
#define YELLOW_LIGHT_4  32
#define GREEN_LIGHT_4   33

MFRC522 rfid1(SS_PIN_1, RST_PIN);
MFRC522 rfid2(SS_PIN_2, RST_PIN);
MFRC522 rfid3(SS_PIN_3, RST_PIN);
MFRC522 rfid4(SS_PIN_4, RST_PIN);

void setup() {
  Serial.begin(9600);
  SPI.begin();
 
  // Initialize RFID readers
  rfid1.PCD_Init();
  rfid2.PCD_Init();
  rfid3.PCD_Init();
  rfid4.PCD_Init();
 
  // Initialize traffic light pins
  pinMode(RED_LIGHT_1, OUTPUT);
  pinMode(YELLOW_LIGHT_1, OUTPUT);
  pinMode(GREEN_LIGHT_1, OUTPUT);
  pinMode(RED_LIGHT_2, OUTPUT);
  pinMode(YELLOW_LIGHT_2, OUTPUT);
  pinMode(GREEN_LIGHT_2, OUTPUT);
  pinMode(RED_LIGHT_3, OUTPUT);
  pinMode(YELLOW_LIGHT_3, OUTPUT);
  pinMode(GREEN_LIGHT_3, OUTPUT);
  pinMode(RED_LIGHT_4, OUTPUT);
  pinMode(YELLOW_LIGHT_4, OUTPUT);
  pinMode(GREEN_LIGHT_4, OUTPUT);
 
  // Set initial state of traffic lights
  setTrafficLight(1, LOW, LOW, HIGH);
  setTrafficLight(2, LOW, LOW, HIGH);
  setTrafficLight(3, LOW, LOW, HIGH);
  setTrafficLight(4, LOW, LOW, HIGH);
}

void loop() {
  // Check each RFID reader for vehicle presence
  checkRFID(rfid1, 1);
  checkRFID(rfid2, 2);
  checkRFID(rfid3, 3);
  checkRFID(rfid4, 4);
}

void checkRFID(MFRC522 &rfid, int lightNumber) {
  if (!rfid.PICC_IsNewCardPresent() || !rfid.PICC_ReadCardSerial()) {
    return;
  }
 
  // Vehicle detected, change traffic light
  setTrafficLight(lightNumber, HIGH, LOW, LOW);
  delay(5000); // Keep red light for 5 seconds
  setTrafficLight(lightNumber, LOW, HIGH, LOW);
  delay(2000); // Yellow light for 2 seconds
  setTrafficLight(lightNumber, LOW, LOW, HIGH);
 
  rfid.PICC_HaltA();
}

void setTrafficLight(int lightNumber, int red, int yellow, int green) {
  switch (lightNumber) {
    case 1:
      digitalWrite(RED_LIGHT_1, red);
      digitalWrite(YELLOW_LIGHT_1, yellow);
      digitalWrite(GREEN_LIGHT_1, green);
      break;
    case 2:
      digitalWrite(RED_LIGHT_2, red);
      digitalWrite(YELLOW_LIGHT_2, yellow);
      digitalWrite(GREEN_LIGHT_2, green);
      break;
    case 3:
      digitalWrite(RED_LIGHT_3, red);
      digitalWrite(YELLOW_LIGHT_3, yellow);
      digitalWrite(GREEN_LIGHT_3, green);
      break;
    case 4:
      digitalWrite(RED_LIGHT_4, red);
      digitalWrite(YELLOW_LIGHT_4, yellow);
      digitalWrite(GREEN_LIGHT_4, green);
      break;
  }
}



 Applications

  • Smart city traffic systems

  • Emergency vehicle priority management

  • Automated toll and traffic monitoring

  • IoT-based transportation projects

  • Engineering and diploma final-year projects

 

IOT & SMART SYSTEM PROJECTS

  1. IoT Weather Monitoring System (NodeMCU ESP8266 + DHT11 + Rain Sensor)
  2. ESP8266 NodeMCU Smart Health & Environment Monitoring System with Pulse, Temperature and Motion Sensors
  3. ESP32 Wi-Fi Weight Sensor with HX711
  4. Smart RFID Access Control System Using ESP32 Dev Board and UHF RFID Reader Module
  5. Smart IoT Motor Control System Using ESP32 Dev Board and L298N Motor Driver Module
  6. Smart Waste Management System Using Arduino Nano, Ultrasonic Sensor & GSM Module – Solar Powered IoT Solution
  7. Raspberry Pi Zero W and GSM SIM900 Based Ultrasonic Distance Measurement System
  8. Arduino UNO Smart Surveillance System with ESP8266 WiFi, PIR Motion Sensor & Camera Module
  9. Arduino UNO Environmental Monitoring System with OLED & 16x2 I2C LCD Display
  10. Arduino UNO-Based Smart Home Automation System with Flame and IR Sensors 
  11. Arduino Nano-Based Landslide Detection System with GSM Alerts – Smart Disaster Monitoring Project
  12. Arduino Nano Rain-Sensing Stepper Motor System
  13. Arduino Based Automatic Tire Inflator Using Pressure Sensor, Relay Module and LCD Display
  14. Arduino-Based Automatic Cooker Using Servo Motors, DC Stirrer Motor, Temperature Sensor and Relay-Controlled Heater
  15. Arduino Sketch for Plastic Bottle and Can Reverse Vending Machine

 TRAFFIC & SMART CITY PROJECTS
  1. RFID-Based Smart Traffic Control System (Arduino Mega)
  2. Arduino UNO Traffic Light Control System – Smart LED Signal Project
  3.  Arduino UNO Controlled Traffic Light System with Joystick Interface

ROBOTICS PROJECTS
  1. Arduino UNO Smart Obstacle Avoiding Robot (Ultrasonic + IR + GSM)
  2. Arduino-Powered Autonomous Obstacle Avoidance Robot with Servo Control
  3. Arduino Nano Bluetooth Controlled Line Follower Robot Using L298N Motor Driver
  4. Arduino UNO Bluetooth Controlled 4WD Robot Car Using L298N Motor Driver
  5. Arduino UNO Multi-Sensor Obstacle Avoidance & Bluetooth Controlled Robot Car Using L298N
  6. Raspberry Pi Motor Control Robot (L298N + Li-ion)
  7. RC Car Simulation with L298N Motor Driver and Joystick Control using Arduino (CirkitDesign Simulation)
  8. Raspberry Pi Robotic Arm Control System with Camera Module and Motor Driver – Smart Automation & Vision-Based Robotics Project
  9. ESP32-Based 4WD Robot Car Using Dual L298N Motor Drivers – Circuit Diagram and IoT Control Project

LORA & WIRELESS COMMUNICATION PROJECTS
  1. Arduino LoRa Communication Project Using Adafruit RFM95W LoRa RadioArduino Nano with RFM95 SX1276 LoRa
  2. Arduino Nano with RFM95 LoRa SX1276 Module – Long Range Wireless Communication Project
  3. Arduino Nano Digital Clock Using DS3231 RTC and TM1637 4-Digit Display – Circuit Diagram and Project Guide

 LED, LIGHTING & DISPLAY PROJECTS
  1. Arduino UNO Controlled NeoPixel Ring Light Show
  2. Wi-Fi Controlled NeoPixel Ring (ESP8266)
  3. Chained NeoPixel Rings with Arduino – Addressable RGB LED Control Project
  4. Arduino Nano-Controlled Lighting System with Gesture and Sound Interaction
  5. Raspberry Pi GPIO Multi-LED Control System – Beginner-Friendly Embedded Electronics Project
  6. 4 Channel Relay Module with Arduino UNO

 SENSOR & DETECTION PROJECTS
  1. Arduino UNO Color Sensor + Proximity System (TCS3200 + Inductive)
  2. Arduino Color Detection Project Using Adafruit TCS34725 RGB Color Sensor
  3. Arduino Gas Leakage Detection and Safety Alert System Using MQ-2 Gas Sensor
  4. MQ-135 Air Quality Detector Using Arduino | Cirkit Designer Simulation Project
  5. Pulse Sensor Using Arduino – Complete Guide with Simulation 
  6. HX711 Load Sensor Demo Using Arduino | Digital Weight Measurement Project
  7. Track Time with DS1307 RTC and Display on Arduino Uno with 16x2 LCD | Cirkit Designer Project
  8. Parking Sensor Simulator using Arduino Uno and HC-SR04 Ultrasonic Sensor

 FUN & INTERACTIVE PROJECTS
  1. Pong Game with Arduino UNO and OLED Display – Project Explanation
  2.   Arduino UNO Bluetooth-Controlled Servo Motor System
  3. Arduino UNO-Based Interactive Touch and Distance Sensing System with LED Indicators and Servo Control

 INDUSTRIAL / AUTOMATION PROJECTS
  1. Arduino UNO Smart Waste Sorting System Using Ultrasonic Sensor, Moisture Sensor, Servo, Stepper Motor and LCD
  2. Arduino-Based Smart Waste Segregation System Using Metal, Plastic and Moisture Sensors with Stepper and Servo Control
  3. ESP32-Based Digital Weighing Scale Using 50kg Load Cell, HX711 Module and 16x2 LCD Display
  4. Arduino-Based Smart Toll Gate Automation System with RFID, GSM, Ultrasonic Sensor and LCD Display

  5. Arduino-Based Automatic Pill Dispenser Machine with LCD Display, Servo Motor and Buzzer Reminder

  6. Arduino UNO Smart Water Quality Monitoring System with pH Sensor, Turbidity Sensor and LCD Display

  7. Arduino-Based Ocean Cleaning Boat Robot with Dual IBT-2 Motor Drivers and Conveyor Belt System

  8. IoT-Based Accident Detection and Health Monitoring System Using Raspberry Pi with GSM, GPS and Camera Integration

  9. Raspberry Pi RFID and Keypad Based Smart Door Lock System with LCD Display and L298N Motor Driver

  10. Smart Shopping Trolley Using Arduino UNO & RFID | Automatic Billing System

  11. Arduino UNO Based Automatic Liquid Hand Sanitizer & Soap Dispenser System

  12. Arduino Based Robotic Weeding Machine with Ultrasonic Obstacle Detection and L298N Motor Driver

  13. Arduino UNO Based Biometric Electronic Voting System with LCD Display and Fingerprint Authentication

  14. Arduino UNO Based Electronic Voting System with ILI9341 TFT Display

Comments