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

lego-traffic-light-frontlego-traffic-light-backlego-led

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:
traffic-light-leds

Step 3: Programming the micro:bit


Our aim is to reproduce the following traffic light sequence:
traffic-light-sequence

Check below for the recommended code:

Solution 1: BasicSolution 2: Advanced
micro-bit-traffic-lights-blocks-1
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.
micro-bit-traffic-lights-blocks-2

Electronic Circuit


bbc-microbit-traffic-light-circuit

Did you like this challenge?

Click on a star to rate it!

Average rating 4 / 5. Vote count: 4

No votes so far! Be the first to rate this post.

As you found this challenge interesting...

Follow us on social media!

Tagged with: ,