TRAFFIC SINGAL USING ARDUINO UNO

TRAFFIC SINGAL USING ARDUINO UNO

Summary

This Arduino project tutorial presents a simple and enjoyable traffic light project suitable for beginners. This project involves using Arduino to create a traffic light simulation that requires minimal code and basic circuit setup. The included video tutorials provide step-by-step instructions, making them accessible even to those new to Arduino projects. The code's internal timer ensures that the traffic light simulation continues until the Arduino is powered off. Whether you're new to Arduino or looking for a fun, hands-on project, these tutorials provide a fun exploration of programming and electronics. Join us on our journey to light up the roads with this exciting traffic light project!

INTRODUCTION

Welcome to the exciting journey through Arduino projects! In this demo, we'll show you how to create a simple yet fun traffic light using Arduino, a fantastic project for beginners. By combining a simple circuit and a little code, you can replicate the functionality of a traffic light in a fun and engaging way. The step-by-step video tutorial below guides you through each step of this project, making it accessible even to those just starting out with Arduino. Get ready to dive into the world of programming and electronics as you bring this awesome traffic light project to life. Let’s light the way together!

COMPONENTS

To create the traffic signal using Arduino UNO you need the following components:

Arduino UNO

Arduino uno is an open-source microcontroller based on the processor ATmega 328P.

6 Analog pin inputs, 14 digital pins, a USB connector, a power jack and an ICSP (in-circuit Serial programming) header.

One of its notable features is the USB interface, enabling easy programming and serial communication. The board can be powered via USB or an external supply (7-12V), with an onboard voltage regulator ensuring a stable 5V supply. A reset button allows for program restarts, and built-in LEDs, including a power indicator and one on pin13, offer visual feedback.

5mm LED RED, YELLOW & GREEN

Breadboards and Jumper Wires

Used to create temporary circuits and connect things that don’t have connections.

Connections

                                 LEDs

                       ARDUINO UNO

               GND pin of all LED

                                  GND

               RED LED VCC PIN

                                   PIN 9

               YELLOW LED VCC PIN

                                   PIN 8

               GREEN LED VCC PIN

                                   PIN 7

 

Ensure that the connections are made accurately on the Arduino this table serves as a quick reference guide for setting up the circuit.

ARDUINO CODE


int red = 9;

int yellow = 8;

int green = 7;

 

void setup(){

 

  pinMode(red, OUTPUT);

  pinMode(yellow, OUTPUT);

  pinMode(green, OUTPUT);

 

}

 

void loop(){

  digitalWrite(red, HIGH);

  delay(20000);

  digitalWrite(red, LOW);

 

  // Yellow stays on for 2 seconds

  digitalWrite(yellow, HIGH);

  delay(2000);

  digitalWrite(yellow, LOW);

 

  digitalWrite(green, HIGH);

  delay(20000);

  digitalWrite(green, LOW);

}

CODE EXPLAINATION

  1. Variable Declarations: int red = 9;int yellow = 8;int green = 7; These lines declare three integer variables red yellow and  green and assign them the pin numbers where the respective LEDs are connected.
  2. Setup Function: pinMode(red, OUTPUT); pinMode(yellow, OUTPUT);pinMode(green, OUTPUT); These lines configure the pins connected to the LEDs as output pins, allowing us to control the LEDs.
  3. Loop Function: digitalWrite(red, HIGH), delay(20000); digitalWrite(red, LOW); This sequence turns on the red LED, waits for 15 seconds, and then turns it off. digitalWrite(yellow, HIGH); delay(2000); digitalWrite(yellow, LOW); This sequence turns on the yellow LED, waits for 2 seconds (as per the modification), and then turns it off. digitalWrite(green, HIGH);delay(20000); digitalWrite(green, LOW); This sequence turns on the green LED, waits for 20 seconds, and then turns it off.
  4. Looping: - Since this code is within the loop()function, it repeats these actions indefinitely, cycling through turning on each LED for a specific duration and then turning it off.

OVERALL FUNCITONALITY

The overall functionality of the project is to simulate a basic traffic light system using Arduino and three LEDs of different colours: red, yellow, and green. The program follows a predefined traffic light sequence commonly found at intersections. The main functionalities can be summarized as follows:

  1. Traffic Light Control: The program controls the illumination of the red, yellow, and green LEDs to replicate the standard traffic light phases: red for stopping, yellow for caution, and green for go.
  2. Sequential Operation: The traffic light operates in a sequential manner, transitioning through the standard traffic light cycle: red, yellow, green, and back to yellow.
  3. Timing Control: Precise timing is implemented using the delay function to simulate the duration of each phase (e.g., 15 seconds for red, 20 seconds for green, 1 second for yellow).
  4. Repetition: The entire sequence of red, yellow, green, and yellow is repeated in a continuous loop, creating a realistic simulation of a traffic light's cyclical behavior.
  5. Configurability: The code allows for easy adjustments to the durations of each phase, making it adaptable to different traffic scenarios or user preferences.

CONCLUSION

In conclusion, the Arduino-based traffic light simulation project successfully emulates the fundamental functionality of a traffic light system. By controlling three LEDs – red, yellow, and green – in a sequential manner, the program replicates the typical traffic signal phases. The code incorporates precise timing through delays, allowing the simulation to mirror the durations associated with each phase.

The project's simplicity and configurability make it an excellent starting point for educational purposes or prototyping in the field of traffic control systems. The sequential operation and repetition in a loop provide a realistic simulation of a traffic light's cyclical behaviour. Moreover, the ability to easily adjust the timing parameters allows for customization, enabling developers to tailor the simulation to specific scenarios or preferences.

While this project serves as a foundational framework, it can be expanded upon for more sophisticated applications. Integration with sensors, additional LEDs, or communication modules could enhance the project's capabilities, making it suitable for broader smart city initiatives or traffic management systems. Overall, the project demonstrates the versatility of Arduino in creating tangible simulations for educational and practical purposes, laying the groundwork for further exploration and innovation in the realm of traffic control and smart city technologies.

Components and Supplies

You may also like to read

Frequently Asked Questions

1. What is the objective of traffic light controller using Arduino?

The objective of a traffic light controller using Arduino is to efficiently and effectively regulate the flow of vehicles at intersections. This device utilizes advanced technology, specifically microcontrollers, sensors, and programming codes, to ensure smooth traffic movement and improve overall road safety. By accurately detecting vehicle presence through sensors such as infrared or ultrasonic detectors, the Arduino-based controller can dynamically adjust signal timings based on real-time data. The result is shorter wait times for drivers and reduced congestion on busy roads. With its programmable capabilities and cost-effectiveness compared to traditional controllers, this solution offers municipalities a reliable means of optimizing their traffic management systems while also reducing energy consumption.

2. How to make traffic light with Arduino Uno?

Creating your own traffic light using an Arduino Uno is a fun and educational project that can be completed with just a few simple steps. First, gather all the necessary materials including the Arduino Uno board, LED lights (red, yellow, green), resistors and breadboard. Next, connect the LEDs to their corresponding digital pins on the board along with their respective resistors. Then write a code in C++ language that will control when each LED turns on or off based on designated time intervals. Finally, test your circuit by uploading the code onto the board and connecting it to a power source. With these simple instructions and some creativity you can have your very own functional traffic light designed with an Arudino Uno!

Back to blog

Leave a comment

Please note, comments need to be approved before they are published.

Components and Supplies

You may also like to read