Case 01: Traffic Lights
To build a traffic light.
A detailed assembly instruction can be downloaded via the below links: Github download
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.
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).
Click "Advanced" to choose "Functions" and click "Make a Function" as the picture shows below.
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.
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.
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.
You can also download it directly below:
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.
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.