BBC micro:bit – Traffic Light

lego-traffic-light-frontIn this challenge we are going to create and program a traffic light using lego bricks, leds and the BBC micro:bit.

Check this video clip of the complete traffic light in operation:

Step 1: Building the traffic light:

Use a few lego bricks to build the traffic light. Include your LEDs within your blocks and connect their pins to the red and black electric wires.

Make sure that you always connect the cathode of the LED (short leg, flat edge of the LED) to a black wire and use a blue or red wire for the other pin (anode).


Step 2: Connecting the traffic light to the BBC micro:bit

We recommend using crocodile clips for this step. Check the diagram below to make the right connections:

Step 3: Programming the micro:bit

Our aim is to reproduce the following traffic light sequence:

Check below for the recommended code:

Solution 1: BasicSolution 2: Advanced
In this solution we are adding a countdown when the green or the red light is on to inform the drivers who are waiting for the number of seconds redmaining before the traffic light changes.

Electronic Circuit


Share Button
Posted in BBC micro:bit, Computer Science Tagged with: ,

Our Latest Book