Traffic Lights

Overview

In this lesson students will program the micro:bit to control external devices to create a traffic light sequence for a pedestrian crossing in the UK. Students will learn the basics of how the traffic lights system works and therefore will improve their knowledge of road safety.

Aims

  • Learn how to program multiple external outputs with the micro:bit to work in conjunction and independently of each other.
  • Gain a basic understanding of the traffic light sequence for a pedestrian crossing in the UK.

Download the Code

MakeCode Editor

Click the button below to download the MakeCode editor code for this lesson. The hex file is contained in a zip folder.

Kindly refer to our download the code page for instructions on how to upload your code onto the micro:bit. Please use instructions set A.

This code can also be uploaded into the MakeCode editor.

Kit Required

Micro:bit

Innovation Board

Speaker

Bi Colour LED Red/Blue

Bi Colour LED Red/Green

Bi Colour LED Red/Yellow

  • Micro USB Cable
  • 4 x Connector Cable

Preparation

  1. Connect the micro:bit to the Innovation board via the edge connector.
  2. Connect the speaker to ADC1 using one of the connector cables. Connect the red/blue LED to ADC2, the red/yellow LED to ADC3 and the red/green LED to IO1 using the other connector cables.
  3. Connect the micro:bit to a computer via the microUSB cable.
  4. Go to the MakeCode website on your computer and open a new project.

Time to Code

What Will Happen

When the micro:bit is powered the red/green LED will show green. If button A is pressed then the traffic light sequence will begin. The green LED will turn off and the yellow LED will light up for 3 seconds before turning off. The red LED will then show show. At the same time the speaker will beep to simulate a pedestrian crossing. This will happen for 10 seconds before the sequence continues to yellow and finally back to green.

Taking it Further

  • Design a 3D model of a traffic light that in corporate the LED devices and the speaker.
  • Adjust the traffic light sequence to simulate traffic lights in other countries around the world.

Keep in touch

We would love to keep you up to date with all of our latest news, offers and new products.

If you would like to subscribe to our mailing list please click the button below.

Contact Us

ScienceScope Limited
Downside School
Stratton-on-the-Fosse
Radstock
BA3 4RJ
enquiries@sciencescope.uk

Follow Us

#digitaleducationjourney