Traffic Light Simulation through Arduino

Traffic Light Simulation using Arduino


Traffic lights are a part of our daily routine and we pass by them from the point we’re rushing for our offices in the morning to the time when we eagerly want to reach home.

These devices are installed wherever one can find a reasonable amount of traffic. The main function of the lights is to control the traffic efficiently and they typically constitute of timers, sensors and traffic monitoring systems.

We will build a traffic light with the help of an Arduino. This exercise will not only make you understand the basics of how an Arduino works, but will also provide you a guideline to solve similar complex problems, while meeting certain specifications. Furthermore, you’ll get the basic know how about how a traffic light functions.

Both UK and USA style lights will be incorporated in the project.

 Materials Required


  • LEDS: 2 red, 2 green and 2 yellow
  • Resistors: (330-1000 Ohm per color)
  • Arduino (MEGA)
  • Soldering Iron and Solder
  • Wire Cutters


  • Arduino IDE


The modern day traffic lights are very smart, comparatively. They not only monitor the traffic, but also alter their light switching timings as per the request of the pedestrians.

For this particular project, we will form a four way intersection, based on a constant time interval for each light. This means that the light will not run according to the traffic volume. Hence, the lights will not be smart enough, but would definitely be cost saving.

LEDs will be used to represent the traffic lights and the logic and function will be performed by the Arduino alone. The code of the Arduino will be such that it will have the knowledge of when to switch on each light with respect to time intervals.

Additionally, the setup will have the capability to convert from USA to UK style lights by just altering a constant in the code. If you wish to use a digital input for coding, then a wire would be required.
(you can read two different loop sequence here)

Wiring Protocols

A single wire is not even required while dealing with the hardware of this project. It’s pretty simple and easy to understand.

  • Start by wiring the first traffic light.

Insert the positive side of the red LED in pin 31. Generally, the longer side is the positive one, but in case they’re of the similar length, then the outer casing plane side is negative and the one that is left is positive.

Figure: LED connection with Arduino Board (Traffic Light simulation using Arduino)
Figure: LED connection with Arduino Board

In pin 30, insert 330 to 1000 Ohm resistor.

Subsequently, solder the remaining end of the resistor to the negative end of the LED. You might choose to trim the wire as per your need. Generally, an LED’s one end is wired to a positive or negative end of the power supply/battery, but that definitely requires a wire.

Pin 30 would be rather be used as our ground in this project and this is not really a common thing to apply in a traffic light simulation.

Traffic Light Simulation using Arduino-Circuit Diagram
Figure: Circuit Diagram for Traffic Light

Possible Next Steps

Future Extension:

It’s totally up to you, if you would do the exact same thing as we taught you in this article, but there a number of possibilities you can apply to extent the scope of your project.

You can incorporate a real traffic light and wire it up, but for this you need to have a complete know how of mains voltage i.e. 120 VAC in the US. Do not even try to attempt this if you are not aware of the functionality and methodology.

So, where exactly can you find the traffic lights? These are available at stores like eBay, antique shops and flea markets. You’d probably be able to find these at a very reasonable price depending on the demand and material quality of the product.

Implications and Conclusion

So all the information stated above is not restricted to traffic lights only. You can try and implement the same methodology to other lights such as for lighting up your house on Christmas. Set the timing intervals right and you’re good to go.

Use time tables effectively to generate better results and while you’ll be practicing, you’ll get better at it and you’ll be able to innovate eventually.

(Complete Code is also available on demand) 

Feel Free to comment below or contact us for further help. Like facebook page for more.
Read more interesting project articles from the same author. 


What do you think?

This site uses Akismet to reduce spam. Learn how your comment data is processed.