LED Traffic Light Project

In this project, we will take a look at building an LED traffic light circuit. This project will involve using a bit of code and a simple circuit which is a good start for beginners.

Without any further delay in the lengthy introduction lets dive directly to the project.

Equipment used-

·      Arduino UNO
·      Red, Yellow and Green LED
·      3 X 100 Ohm resistors
·      Breadboard
·      Breadboard Wires

LED Traffic Light Circuit

The circuit is simple and easy and making the connections won’t take enough time.

  • Pin 11 goes to the positive leg (longer leg) of the green LED.
  • Pin 12 Goes to the positive leg of the yellow LED.
  • Pin 13 Goes to the positive leg of the red LED.
  • Add a 100-ohm resistor to each of the negative LED legs (shorter leg) and have it connected to GND.

For better understanding of the connections a circuit diagram is provided above.

LED Traffic Light Code

If a person has a little bit of programming experience (in any language) he will surely get the logic behind every line of code.

But I will break down the code for you.

The pins on the Arduino can be configured as either inputs or outputs.

pinMode Configures the specified pin to behave either as an input or an output. It returns nothing. Its syntax is:

pinMode(pin, mode)  where,

pin: the Arduino pin number to set the mode of.

Therefore, we have configured our pins 11, 12, 13 for our project.

If the pin has been configured as an OUTPUT with pinMode(), its voltage will be set to the corresponding value: 5V (or 3.3V on 3.3V boards) for HIGH, 0V (ground) for LOW. It returns nothing. Its syntax is:

digitalWrite(pin, value) where,

pin: the Arduino pin number.
value: HIGH or LOW.

Here is the code:

The Arduino Code

I hope you have enjoyed this LED traffic light project if you have any questions, then please don’t hesitate to mail me.

Leave a Comment

Your email address will not be published. Required fields are marked *

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