Microbit
Beginner
30 mins
125 points
What you need:
  • Chromebook/Laptop/PC
  • Microbit
  • Traffic Lights Kit

Lights Show

Make your Traffic Lights put on a lights show!

1 - Introduction

We're going to put on a lights show using your Microbit and your Traffic Lights Kit so you'll need to connect your Microbit to your Traffic Lights.

Take a look at the "Build your Traffic Lights" lesson if you need instructions.


2 - Create a new Microbit project

Go to the makecode.com website and create a new Microbit project.

3 - Add the Stopbit extension

There are custom code blocks that we use to program our traffic lights kit. To add them to our toolbox we need to add the "stopbit" extension.

Search for the "stopbit" extension and then click on the traffic lights kit picture.

This will add the "Kitronik STOP:bit" category of code blocks to your toolbox.



4 - Program the A button

We're going to program the A button on our Microbit to make the traffic lights turn on and off the lights in a sequence. The sequence will be:

  1. turn on Red
  2. turn off Red
  3. turn on Yellow
  4. turn off Yellow
  5. turn on Green
  6. turn off Green

We also need to put in a little pause after each step, otherwise it will happen to fast and we won't see the lights effect we are creating! Add the following code.

5 - Make it loop

At the moment pressing the A button will just run through the sequence once. So let's put the sequence inside a loop block so that it repeats the sequence 10 times.


Once you have added in the 'repeat' block, download your code to your computer and send it to your Microbit. Press the A button and test that it shows the lights sequence 10 times. If it doesn't, check your code to see if you have missed anything.



Join our club 😃

To view the remaining 3 steps and access hundreds of other coding projects please login or create an account.

Copyright Notice
This lesson is copyright of Coding Ireland. Unauthorised use, copying or distribution is not allowed.
🍪 Our website uses cookies to make your browsing experience better. By using our website you agree to our use of cookies. Learn more