4. Case 01: Traffic Lights#

4.1. Purpose#

To build a traffic light.

../../_images/Ringbit_Bricks_Pack_case_en_01_01.png

4.3. Materials#

../../_images/Ringbit_Bricks_Pack_case_en_01_02.png

4.4. Background Knowledge#

4.5. Bricks build-up#

../../_images/Ringbit_Bricks_Pack_step_01_01.png

../../_images/Ringbit_Bricks_Pack_step_01_02.png

../../_images/Ringbit_Bricks_Pack_step_01_03.png

../../_images/Ringbit_Bricks_Pack_step_01_04.png

../../_images/Ringbit_Bricks_Pack_step_01_05.png

../../_images/Ringbit_Bricks_Pack_step_01_06.png

../../_images/Ringbit_Bricks_Pack_step_01_07.png

../../_images/Ringbit_Bricks_Pack_step_01_08.png

../../_images/Ringbit_Bricks_Pack_step_01_09.png

../../_images/Ringbit_Bricks_Pack_step_01_10.png

../../_images/Ringbit_Bricks_Pack_step_01_11.png

../../_images/Ringbit_Bricks_Pack_step_01_12.png

../../_images/Ringbit_Bricks_Pack_step_01_13.png

../../_images/Ringbit_Bricks_Pack_step_01_14.png

A detailed assembly instruction can be downloaded via the below links: Github download

4.6. Software#

MicroSoft makecode

4.7. Programming#

Step 1#

Click “Advanced” in the MakeCode drawer to see more choices.

../../_images/Ringbit_Bricks_Pack_case_en_01_03.png

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.

../../_images/Ringbit_Bricks_Pack_case_en_01_04.png

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).

../../_images/Ringbit_Bricks_Pack_case_en_01_05.png

Step 3#

Click “Advanced” to choose “Functions” and click “Make a Function” as the picture shows below.

../../_images/Ringbit_Bricks_Pack_case_en_01_06.png

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.

../../_images/Ringbit_Bricks_Pack_case_en_01_07.png

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.

../../_images/Ringbit_Bricks_Pack_case_en_01_08.png

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.

../../_images/Ringbit_Bricks_Pack_case_en_01_09.png

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.

4.8. Exploration#

4.9. FAQ#

4.10. 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.