IOT

Traffic Light Controller Using Arduino

In this present era, the concept of a smart city depends on the technologies adopted to improve people’s quality of life. The Smart Traffic Management system is one of the most inevitable factors in the development of a country. In today’s world Internet of Things plays an important role in many applications such as smart home, smart transportation systems, etc. 

The Arduino is the most widely used open-source microcontroller board, which is utilised in a wide range of electronics and DIY projects. This project is an Arduino-based traffic light controller. It is an electronic project that will explain to us about traffic lights and how they function. This project is a simplified version of a traffic signal system that we have shown for three sides or directions.

Why Traffic Light System?

Roads that are not supervised or guided might result in traffic jams and accidents. For a smooth flow of traffic, traffic signals are essential. A traffic signal is a device that instructs road users to act in accordance with the displayed sign.

The use of traffic lights allows everyone to cross the intersection point one at a time, reducing disputes between vehicles approaching from various directions. It ensures road safety while also assisting in the straightforward resolution of traffic congestion.

Traffic lights come in a variety of colours. Each light has a purpose, and these lights instruct drivers on how to proceed.

  • Red light ON- A driver should stop.
  • Yellow light ON- A driver has to slow down and be ready to stop.
  • Green light ON- A driver can start driving or keep driving.

Components Required

  • Arduino Uno
  • Breadboard
  • LEDs ( Red, Yellow, Green)
  • Resistor( 220 Ohm)
  • Dupont cables.

Circuit Connection (LED with Arduino)

Connection diagram of traffic light signal using Arduino.

This is the circuit diagram for the traffic light controller by using Arduino.

  • Connect LEDs on the breadboard as Red, Yellow, Green, respectively.
  • Connect the negative terminal of the LED and connect the 220 Ohm resistor in series.
  • Connect these negative terminals to the ground.
  • Connect the positive terminal of the LEDs to the pins 2 to 10, respectively.
  • Power the breadboard by using 5V and GND on the Arduino.

The logic of This Traffic Light System Using Arduino Code

This traffic light controller’s code is straightforward and simple to comprehend. We have traffic lights for a three-way road on display. The LEDs will light up in a specific order to create a traffic light controller system.

Two red LEDs will glow at the same time, while one green LED will be turned on. Two yellow LEDs will also be turned on for one second. Each time the colour changes from red to green, a yellow LED will light up. In short, the RED LED will glow for 5 seconds, followed by the YELLOW LED for 1 second, and finally, the Green LED for 5 seconds.

In the void setup of the code, we have defined the pins for the LEDs as outputs from 2 to 10. In the void loop section, we have defined the functions to turn LEDs ON and OFF into the sequence.

Code & Software

Upload the following code in the Arduino software.



void setup() {
// configure the output pins
pinMode(2,OUTPUT);
pinMode(3,OUTPUT);
pinMode(4,OUTPUT);
pinMode(5,OUTPUT);
pinMode(6,OUTPUT);
pinMode(7,OUTPUT);
pinMode(8,OUTPUT);
pinMode(9,OUTPUT);
pinMode(10,OUTPUT);
}

void loop()
{
digitalWrite(2,1); //enables the 1st set of signals
digitalWrite(7,1);
digitalWrite(10,1);
digitalWrite(4,0);
digitalWrite(3,0);
digitalWrite(6,0);
digitalWrite(8,0);
digitalWrite(9,0);
digitalWrite(5,0);
delay(5000);

digitalWrite(3,1); //enables the yellow lights
digitalWrite(6,1);
digitalWrite(2,0);
digitalWrite(7,0);
delay(1000);

digitalWrite(4,1); //enables the 2nd set of signals
digitalWrite(5,1);
digitalWrite(10,1);
digitalWrite(2,0);
digitalWrite(3,0);
digitalWrite(6,0);
digitalWrite(8,0);
digitalWrite(9,0);
digitalWrite(7,0);
delay(5000);

digitalWrite(9,1); //enables the yellow lights
digitalWrite(6,1);
digitalWrite(10,0);
digitalWrite(5,0);
digitalWrite(4,0);
delay(1000);

digitalWrite(8,1); //enables the 3rd set of signals
digitalWrite(4,1);
digitalWrite(7,1);
digitalWrite(2,0);
digitalWrite(3,0);
digitalWrite(5,0);
digitalWrite(6,0);
digitalWrite(9,0);
digitalWrite(10,0);
delay(5000);

digitalWrite(9,1); //enables the yellow lights
digitalWrite(3,1);
digitalWrite(7,0);
digitalWrite(8,0);
digitalWrite(4,0);
delay(1000);
}

Output:

Output of traffic light control system

The output of the traffic light control system.

Advantages

  • This system’s traffic light controller can be used in practice, and it can be expanded further by you.
  • A crosswalk signalling mechanism is included in this traffic light controller.
  • External memory can be interfaced with the central controller, allowing the timings to be programmed during operation rather than during programming.

Disadvantages

  • The project is not intended for actual implementation, but more as a demonstration of the system’s process.
  • The project can be run manually or with the help of pre-programmed activities. It is unable to function in both directions.
  • The operator of a real-time traffic control system has the ability to adjust the timings and intensity of each lane’s traffic signal.

FUTURE SCOPE 

  • In the future, the model ambulance can be able to communicate with all base stations to get an easy free lane, to rush up reaching the hospital on time for needy people.
  • An IOT-based real-time traffic monitoring system is proposed for the dynamic handling of traffic signals based on traffic density.
  •  Provides a real-time dashboard to monitor the traffic updates.
  • This can save their time expansion for reaching the proposed destination and can prevent the loss of human life up to the great extent

Leave a Reply

Your email address will not be published.