Project 02: Traffic Lights

1. Overview

In this project, we adopt three LEDs( red, yellow and green), a speaker on micro:bit board and 5x5 LED matrix to make a model of traffic lights.

2. Components

Img

Img

Img

micro:bit board *1

micro:bit T-type expansion board *1

micro USB cable *1

Img

Img

Img

red LED *1

yellow LED *1

green LED *1

Img

Img

Img

220Ω resistor *3

jump wires

breadboard *1

Img

Img

battery holder *1
(self-provided AA batteries *2)

traffic lights card *1

3. Components Knowledge

Speaker

Img

Micro: bit comes with a speaker, which makes it easy to make sound in your project.

4. Wiring Diagram

Img

Note: the micro:bit board needs to be inserted into the T-type expansion board as shown below. The micro:bit board LED matrix should be on the same side with the logo of the expansion board.

Img

5. Code Flow

Img

6. Test Code

The code file is provided in folder Project 02:Traffic Lights, file Project-02-Traffic-Lights.hex.

Img

Load code blocks:

Img

7. Test Result

For Windows 10 App, click “Download” . For browsers, send the downloaded “.hex” file to the micro:bit board.

After downloading the code to the board, the green LED turns on and the 5×5 LED matrix counts down 6 seconds. After the green LED is off, the yellow LED flashes and the matrix counts down 3s with speaker sounding. At last, the red LED is on with a countdown of 6s. These actions repeat.

ATTENTION: If the wiring is correct but you cannot see the results, press the reset button on the back of the board.

Img

When powering on via external power supply, turn the DIP switch to ON.

Img