Arduino How to Control Traffic Lights

by RonFrtek in Circuits > Arduino

1057 Views, 4 Favorites, 0 Comments

Arduino How to Control Traffic Lights

How to Control Traffic Lights with Arduino

In this tutorial we will learn how to control traffic lights using arduino and Visuino.
This tutorial is great for beginners.

Watch the video.

What You Will Need

VisuinoAdvrtisementM5Stack8.jpg
images (3).jpg
FZEK4WBK3XGYAP0.LARGE.jpg
F5OFEUQJJ4ZYFKY.LARGE.jpg
New-Mini-Universal-Test-Protoboard-400-Tie-Points-PCB-Breadboard-for-Arduino.jpg

  • Arduino UNO (or any other Arduino)
  • Traffic lights module
  • Jumper wires
  • Breadboard
  • Visuino program: Download Visuino

The Circuit

traffic-light.jpg
  • 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

F4GNY5CK54FYLVR.LARGE.jpg
FBL8FPKK5H5EPPI.LARGE.jpg

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 Instructable will not work! If you have not done follow the steps in this Instructable to setup 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 on Picture 2

In Visuino ADD Components

2020-04-27_13-10-29.jpg
2020-04-27_13-24-06.jpg
2020-04-27_13-11-24.jpg
2020-04-27_13-11-49.jpg
2020-04-27_13-12-03.jpg
2020-04-27_13-12-17.jpg
  • 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

2020-04-27_13-18-29.jpg

  • 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

upload.jpg

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 Instructable, you can download it and open it in Visuino: https://www.visuino.eu