Arduino Mini Project For beginners: Automatic Traffic Signal Controller

Arduino Mini Project For beginners – Simple program Free Download

Arduino_UnoWe have already seen How to install and run Arduino.

We have also seen the most basic and Simple Arduino program: LED Blink. In that program we came know that how to make a single LED to blink for a given time of period.

In this project, we are going to see How to control three different colored LED lights glowing one at a time. In real-time application, we can call it as Traffic Signal Controller project.

Traffic Signal Controller(Automatic) Program Step by Step Explanation:

As we know that a traffic signal has three colored Lights, “Red, Green, Yellow”. Similarly here also we have three LED lights connected to three output pins:

As we may get confused of pin numbers while programming, we declare variables for those pins as follows:

Next we have to define the output pins within the function void setup() as follows.

Here we use variable to specify output pin numbers as they are declared already.

  • Now our next step is to code within the function void loop().  
  • Here we write the coding for changing the signal.i.e., the  lights will change their status (ON or OFF ) one after the other .
  • To say clear, as in traffic signal any one light should be in ON for a particular period of time while the other lights will be in OFF.
  • This rule is applied for all the three lights within a specific interval of time.

To make coding easier and more understandable, we are creating a new function called ChangeSignal(),  just outside the function void loop(). Then we call this function (ChangeSignal) within the loop()  function.

Coding to Change Signal:

We know that to make an LED to Blink we use the code:

Similarly to stop an LED from blinking we use

Now lets see how to make three lights glowing one after other with a delay of specific time period.

First we are going to make all the lights OFF and GREEN_LED alone ON.

Now OFF the GREEN and YELLOW_LED glows for 3 seconds.

Now OFF the YELLOW and make RED_LED ON for 5 seconds.
Turn off yellow, then turn red on for 5 seconds

Now we use all the above said codes into ChangeSignal(). Now while calling this ChangeSignal() function within loop(), we set all the entire function to be called once after every 15 seconds such that the changing of lights will be clearly visible.

Now see for the complete coding of Traffic signal Controller (Automatic).

Traffic signal Controller Project Arduino Sketch (Coding):

Hope you understand how to program in Arduino using this simple Arduino project – Traffic Signal Controller.

Try this example and try your own fun arduino programs….

Read More:

555 Timer Projects for Beginners – 555 Timer Delay Circuit Design
555 Timer based LED Project
Simple LED Flasher Circuit using Opamp

Thanks for reading…. Please leave your comments below…

You may also like...

Leave a Reply

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

Time limit is exhausted. Please reload CAPTCHA.