Sunday, January 4, 2026

Density-Based Traffic Light Controller

efy-tested-1

Efficient traffic management in urban areas remains a significant challenge as vehicle density grows and infrastructure struggles to keep pace. Conventional traffic lights rely on fixed timers, which often result in unnecessary delays and congestion during low-traffic periods. To address this, an intelligent traffic signal control system has been developed using low-cost, readily available components, including Arduino Uno and Arduino Nano boards and HC-SR04 ultrasonic sensors. Four ultrasonic sensors continuously monitor vehicle presence across four lanes. The sensor unit (Arduino Uno) collects proximity data and sends it via I2C communication to the control unit (Arduino Nano), which adjusts signal timing in real time.

When a vehicle is detected in a lane, that lane receives a 10-second green light. If no vehicle is present, the green phase is limited to a pre-timed 2 seconds. After the green interval, the signal automatically switches to red, and the system advances to the next lane. The distance readings from each lane are updated on the serial monitor every second.

RGB LEDs indicate the traffic signal status (green/red), and the system logs its control sequence through the serial monitor. The modular, low-cost architecture enables straightforward scaling for additional lanes or future IoT enhancements. Fig. 1 presents a prototype of the system setup, and Fig. 2 provides the corresponding block diagram.

- Advertisement -
Density-Based Traffic Light Controller
Fig. 1: Prototype of the proposed setup for optimised traffic control
Density-Based Traffic Light Controller
Fig. 2: Block diagram

Two Arduino boards are used in the system. One functions as the sensor device and the other acts as the controller device. Both communicate over the I2C line. The sensor device detects vehicles using ultrasonic sensors, while the controller operates the RGB LED for signal indication. These components form the core of the system design. The required components are listed in Table 1 for the Bill of Materials.

Table 1 Bill of materials
ComponentQuantityDescription
Arduino Uno R3 (MOD1)1Control unit (master)
Arduino Nano (MOD2)1Sensor unit (slave)
HC-SR04 ultrasonic sensor (U1-U4)4Distance sensing for each lane
RGB LEDs (common cathode) (LED1-LED4)4Red and green signal simulation
Jumper wires30+Wiring between boards and components
Breadboard1For mounting and layout
USB cable (mini type B)1 eachProgramming and powering the boards

Table 2 summarises the signal behaviour of the smart traffic control system based on real-time vehicle detection. It outlines how the system dynamically adjusts the durations of the green and red LED indicators based on traffic conditions in each lane.

- Advertisement -
Table 2 Condition-Behaviour Correlation
ConditionSignal PhaseDurationLED Behaviour
Vehicle detectedGreen10 secondsGreen on, red off
Vehicle not detectedGreen2 secondsGreen on, red off
After green (transition)Red (all lanes)2 secondsRed on, green off
Other lanes (idle)RedUntil the cycle repeatsRed on, green off

Design, working, and setup

The system has been developed as a dynamic traffic signal control system using Arduino Uno and Arduino Nano, designed to operate based on real-time vehicle detection across four lanes. HC-SR04 ultrasonic sensors detect vehicle presence and RGB LEDs simulate traffic signals. Communication between the two Arduino boards is established via the I2C protocol, ensuring coordinated sensing and signal control. The setup demonstrates intelligent lane management using low-cost and widely available hardware components.

The system is divided into two functional units: the sensor unit (Arduino Uno, master) and the control unit (Arduino Nano, slave).

In the sensor unit, the Arduino Uno (master) continuously reads distance values from four ultrasonic sensors, each allocated to one lane. Vehicle presence is determined by comparing the measured distance against a fixed threshold of less than 15cm. The detection status for all four lanes is encoded into a single byte and transmitted to the control unit via I2C communication.

In the control unit, the Arduino Nano (slave) continuously receives detection data from the Uno and determines the traffic signal duration for each lane. If a vehicle is detected in a lane, the Nano activates the green LED for 10 seconds. If no vehicle is detected, the system provides a brief 2-second green phase to minimise unnecessary waiting. During this time, all other lanes remain red. The process cycles through all four lanes, dynamically optimising the signal timing in response to real-time traffic flow.

This intelligent timing approach reduces idle waiting periods at intersections and enhances traffic efficiency, particularly during uneven or fluctuating traffic conditions.

Circuit diagram

The complete circuit diagram of the proposed system is shown in Fig. 3. It is built around an Arduino Uno, an Arduino Nano, four ultrasonic sensors, four common-cathode RGB LEDs, and a few other supporting components. The Arduino Uno and Nano communicate through the I2C interface using pins A4 (SDA) and A5 (SCL). The controller (Arduino Nano) receives sensor data via I2C and controls the RGB LEDs accordingly to simulate the traffic signal operation.

Density-Based Traffic Light Controller
Fig. 3: Circuit diagram

There are two types of RGB LEDs available in market: common cathode and common anode. Their wiring differs accordingly. For a common-cathode RGB LED, the common pin is connected to GND, while for a common-anode RGB LED, it is connected to VCC. In this system, common-anode RGB LEDs have been used; therefore, the common terminal is connected to VCC. Table 3 explains the connections and functions of the various components used in the system.

Table 3 Connections among the various components
Arduino UnoArdino NanoSensor U4 Lane 1Sensor U3 Lane 2Sensor U3 Lane 3Sensor U1 Lane 4RGB5VGND
D2, D3
Trig, Echo




MOD1-GND
D4, D5

Trig, Echo




D6, D7


Trig, Echo



D8, D9



Trig, Echo



D2 D3



R – LED1 G – LED1LED1-CMOD2-G

D4 D5



R – LED2 G – LED2LED2-C

D6 D7



R – LED3 G – LED3LED3-C

D8 D9



R – LED4 G – LED4LED4-C
SDA, SCLA4, A5






GNDGNDGNDGNDGNDGND

GND
5V5V5V5V5V5V5V5V

Software

EFY Icon

EFY++ CONTENT: ACCESS TO THIS CONTENT IS FREE! BUT YOU NEED TO BE A REGISTERED USER.

Oops! This is an EFY++ article, which means it's our Premium Content. You need to be a Registered User of our website to read its complete content.

Good News: You can register to our website for FREE! CLICK HERE to register now.

Already a registered member? If YES, then simply login to you account below. (TIP: Use 'forgot password' feature and reset and save your new password in your browser, if you forgot the last one!)

Geetali Saha
Geetali Saha
Dr Geetali Saha (left) is a faculty member in the Department of Electronics and Communication Engineering, GCET, Anand, Gujarat.

SHARE YOUR THOUGHTS & COMMENTS

EFY Prime

Unique DIY Projects

Truly Innovative Electronics

Electronics News

Latest DIY Videos

Electronics Components

Electronics Jobs

Calculators For Electronics

×