In this tutorial we will learn how to control a traffic light using a Membrane Keypad and Arduino.
Also checkout this tutorial: https://www.instructables.com/Arduino-How-to-Control-Traffic-Lights/
Watch the video.
Step 1: What You Will Need
- Arduino UNO (or any other Arduino)
- Membrane Keypad
- Traffic lights module
- Jumper wires
- Visuino program: Download Visuino
Step 2: Brought by PCBWay
Thank you PCBWay for supporting this tutorial and helping users learn more about electronics.
NEW! Now you can get Aluminum PCB & FLEX PCB in their Special Offer!
What I like about the PCBWay is that you can get 10 boards for approximately $5 which is really cost effective for professional made boards, not to mention how much time you save!
Go check them out here. They also offer a lot of other stuff in case you might need it like assembly, 3D printing, CNC machining and a lot more.
Step 3: The Circuit
- Connect “Traffic lights module” pin [GND] to Arduino pin[GND]
- Connect “Traffic lights module” pin [R] to Arduino digital pin[11]
- Connect “Traffic lights module” pin [Y] to Arduino digital pin[12]
- Connect “Traffic lights module” pin [G] to Arduino digital pin[13]
- Connect Membrane Keypad pin [1] to Arduino digital pin[2]
- Connect Membrane Keypad pin [2] to Arduino digital pin[3]
- Connect Membrane Keypad pin [3] to Arduino digital pin[4]
- Connect Membrane Keypad pin [4] to Arduino digital pin[5]
Step 4: Start Visuino, and Select the Arduino UNO Board Type
The Visuino: https://www.visuino.com also needs to be installed. Download Free version or register for a Free Trial.
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 5: In Visuino Add Components
- Add “Keypad” component
- Add 3X “Digital Multi Source” component
- Add 3X “Toggle(T) Flip-Flop” component
- Add “Pulse Generator” component
Step 6: In Visuino Set Components
- Select “Keypad1″ and in the properties window set “Columns Output Pins” to 3
- Double click on the “Keypad1” and in the “Keys” window drag 3X “Digital Key” to the left side
- Close the window
- Select “DigitalMultiSource1” and in the properties window set “Output Pins” to 3
- Select “DigitalMultiSource2” and in the properties window set “Output Pins” to 3
- Select “DigitalMultiSource3” and in the properties window set “Output Pins” to 3
- Select “PulseGenerator1” and in the properties window select “Enabled” and click on the Pin icon and select “Boolean SinkPin“
Step 7: In Visuino Connect Components
- Connect Arduino Digital Pin[2] to “Keypad1” > Rows Pin [0]
- Connect “Keypad1” > Columns Pin [0] to Arduino Digital Pin[3]
- Connect “Keypad1” > Columns Pin [1] to Arduino Digital Pin[4]
- Connect “Keypad1” > Columns Pin [2] to Arduino Digital Pin[5]
- Connect “Keypad1” > Keys > Digital Key1 Pin [Out] to “DigitalMultiSource1” Digital Pin[In]
- Connect “Keypad1” > Keys > Digital Key2 Pin [Out] to “DigitalMultiSource2” Digital Pin[In]
- Connect “Keypad1” > Keys > Digital Key3 Pin [Out] to “DigitalMultiSource3” Digital Pin[In]
- Connect “DigitalMultiSource1” Digital Pin[0] to “TFlipFlop1” pin [Clock]
- Connect “DigitalMultiSource1” Digital Pin[1] to “TFlipFlop2” pin [Reset]
- Connect “DigitalMultiSource1” Digital Pin[2] to “TFlipFlop3” pin [Reset]
- Connect “DigitalMultiSource2” Digital Pin[0] to “TFlipFlop2” pin [Clock]
- Connect “DigitalMultiSource2” Digital Pin[1] to “TFlipFlop1” pin [Reset]
- Connect “DigitalMultiSource2” Digital Pin[2] to “TFlipFlop3” pin [Reset]
- Connect “DigitalMultiSource3” Digital Pin[0] to “TFlipFlop3” pin [Clock]
- Connect “DigitalMultiSource3” Digital Pin[1] to “TFlipFlop1” pin [Reset]
- Connect “DigitalMultiSource3” Digital Pin[2] to “TFlipFlop2” pin [Reset]
- Connect “TFlipFlop1” pin [Out] to Arduino Digital Pin[11]
- Connect “TFlipFlop2” pin [Out] to “PulseGenerator1” Pin[Enabled]
- Connect “TFlipFlop2” pin [Inverted] to “PulseGenerator1” Pin[Reset]
- Connect “PulseGenerator1” Pin[Out] to Arduino Digital Pin[12]
- Connect “TFlipFlop3” pin [Out] to Arduino Digital Pin[13]
Step 8: 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 9: Play
If you power the Arduino UNO module and press the membrane button, the traffic light module will start to change colors according to the pressed button.
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.
Download Traffic-Lights-keypad