How to Simulate the Operation of Traffic Light?
Overview
When walking at the crossroad, you can see the traffic light command the orderly movement of pedestrians and vehicles. So how is the traffic light controlled to operate? In this project, we will connect a traffic light module to our sensor shield, controlling traffic light blink with micro:bit. You will learn how to simulate the operation of traffic light.
Component Introduction
Traffic Light Module:
When learning the microcontroller, you may usually use three separate LEDs (red, green and yellow) to simulate the traffic light blinking. In this way you may need more wire connection. We specially design this traffic light module, which is very convenient for wiring. It has integrated three LEDs (red, green and yellow) together on the module. Also breaks out four pin interfaces. There are two positioning holes for easy installation.
Component Required:
-
Micro:bit main board *1
-
Keyestudio Micro bit Sensor V2 Shield *1
-
USB Cable *1
-
Keyestudio Traffic Light Module *1
-
DuPont jumper wire *4
-
Premium Battery Holder 6-cell AA*1
-
1.5V AA Battery*6
Connection Diagram
Test Code
Test Results
Done wiring and powered up, send the code to micro:bit, eventually you should see the green LED lights 5 seconds then off, and yellow LED starts to blink 3 times with an interval of 0.5 second, then off, followed by red LED lights up for 5 seconds then off. Up to this moment, green LED lights again, forming a loop cycle.