Arduino How to Control Traffic Lights
2026-09-09 | By Ron Cutts
License: GNU Lesser General Public License LED Strips Microcontrollers PWM Serial / UART Arduino ESP32
In this tutorial, we will learn how to control traffic lights using Arduino and Visuino.
This tutorial is great for beginners.
Watch the video.
Learn more about Visuino: What is Visuino
What You Will Need
Arduino UNO (or any other Arduino)
Visuino program: Download Visuino





The Circuit
Connect "Traffic lights module" pin [GND] to Arduino pin[GND]
Connect "Traffic lights module" pin [R] to Arduino digital pin[2]
Connect "Traffic lights module" pin [Y] to Arduino digital pin[3]
Connect "Traffic lights module" pin [G] to Arduino digital pin[4]

Start Visuino, and Select the Arduino UNO Board Type
To start programming the Arduino, you will need to have the Arduino IDE installed from here: https://www.arduino.cc/.
Please be aware that there are some critical bugs in Arduino IDE 1.6.6. Make sure that you install 1.6.7 or higher; otherwise, this will not work! If you have not done so, follow the steps to set up the Arduino IDE to program Arduino UNO! The Visuino: https://www.visuino.eu also needs to be installed. Start Visuino as shown in the first picture. Click on the "Tools" button on the Arduino component (Picture 1) in Visuino. When the dialog appears, select "Arduino UNO" as shown in Picture 2


In Visuino ADD Components
Add "Sequence" component
Select "Sequence1" component and in the properties window set "Repeat" to: True, this will enable to repeat the whole process over and over meaning the lights will continue to flash
Double click on "Sequence1" component
in the "Elements" window drag 3X "Digital Period" to the left
On the left side of the "Elements" window select "Digital Period1" and in the properties window set "Delay" to 3000 <<This is the time after (3s) for the first light to flash
On the left side of the "Elements" window select "Digital Period2" and in the properties window set "Delay" to 6000 <<This is the time after start(6s) for the second light to flash
On the left side of the "Elements" window select "Digital Period3" and in the properties window set "Delay" to 9000 <<This is the time after start(9s) for the third light to flash
Close the "Elements" window






In Visuino Connect Components
Connect "Sequence1" > "Digital Period1" pin[Out] to Arduino board digital pin[2]
Connect "Sequence1" > "Digital Period2" pin[Out] to Arduino board digital pin[3]
Connect "Sequence1" > "Digital Period3" pin[Out] to Arduino board digital pin[4]

Generate, Compile, and Upload the Arduino Code
In Visuino, at the bottom click on the "Build" Tab, make sure the correct port is selected, then click on the "Compile/Build and Upload" button.

Play
If you power the Arduino UNO module, the traffic lights module will start to change colors in a sequence.
Congratulations! You have completed your project with Visuino. Also attached is the Visuino project that I created for this. You can download it and open it in Visuino: https://www.visuino.eu

