3.
Case 01: Traffic Lights
3.2. Materials
A detailed assembly instruction can be downloaded via the below links: Github download
3.5. Software
MicroSoft makecode
3.6. Programming
Step 1
Click “Advanced” in the MakeCode drawer to see more choices.
In order to programme for the Ring:bit Bricks Pack, we need to add an extension. Click “Extensions” at the bottom
of the drawer. Search “Ringbit” in the dialogue box to download it.
Note: If you met a tip indicating codebase will be deleted due to incompatibility, you may continue as the tips tell
or build a new project.
Step 2
Drag the set strip to NeoPixel at pin with led as to on start, set the pin at P0 port. Initialize the strip in
3 LEDs and in RGB(GRB format).
Step 3
Click “Advanced” to choose “Functions” and click “Make a Function” as the picture shows below.
Step 4
Enter “Red LED lights on” and click “Done” to create a function, and create another two functions “Yellow LED
lights on”, “Green LED lights on” in the same way.
Step 5
In the function of “Red LED lights on”, set the third LED in red and the other two in black; in “Yellow LED lights
on”, set the second LED in yellow and the other two in black; in “Green LED lights on”, set the first LED in green
and the other two in black.
Step 6
Set “red led lights on” function in “Forever”, and pause 3000ms; Set “yellow led lights on” function and pause
1000ms; set “green led lights on” and pause 3000ms.
Code
Link: https://makecode.microbit.org/_DdAU5d4kMJDh
You can also download it directly below:
### Result
When power on, the red LED lights on for 3 seconds, then the yellow led in 1 second and the green one in 3
seconds at last.
3.7. Exploration
3.8. FAQ
3.9. Relevant File
On December 10th, 1868, the first signal light was born in the square of the London House of Parliament. It was
designed and manufactured by the British mechanic De Hart. The lamp post is 7 meters high with a red and green
lantern hanging there –Gas traffic signal light (the color of the light is controlled manually by the police on duty),
this is the first signal light in the street. Unfortunately, the gas traffic light suddenly exploded killing a police officer
on duty on the lamp’s twenty-third birth day. The city’s traffic lights have been banned since then. It was not until
1914 that the city of Cleveland took the lead in restoring traffic lights (electrical signals). In 1918, The traffic
policeman William Potts from Detroit invented the first signal light consisting of red, green and yellow.