Arduino How To Control Traffic Lights
About the project
In this tutorial we will learn how to control traffic lights using arduino and Visuino. This tutorial is great for beginners.
Project info
Difficulty: Easy
Platforms: Adafruit, Arduino, Visuino
Estimated time: 1 hour
License: GNU General Public License, version 3 or later (GPL3+)
Items used in this project
Hardware components
Story
In this tutorial we will learn how to control traffic lights using arduino and Visuino.This tutorial is great for beginners.
Watch the video.
Step 1: What You Will Need
1 / 4
- Arduino UNO (or any other Arduino)
- Traffic lights module
- Jumper wires
- Breadboard
- Visuino program: Download Visuino
Step 2: 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]
Step 3: Start Visuino, and Select the Arduino UNO Board Type
1 / 2
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 tutorial will not work! If you have not done follow the steps in this tutorial 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
Step 4: In Visuino ADD Components
1 / 6
- 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
Step 5: 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]
Step 6: 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.
Step 7: 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 tutorial, you can download it and open it in Visuino: https://www.visuino.eu
Leave your feedback...