Create your own micro:bit traffic light add-on board.
Overview
By the end of this tutorial you will know what an LED is and how to connect and program them using a BBC micro:bit.
What You Will Need
1 x Red LED
1 x Yellow LED
1 x Green LED
1 x Piece of cardboard
Copper tape / aluminium foil and glue
4 x Crocodile / alligator leads
1 x micro:bit (version 1 and 2 will work)
1 x Micro USB cable
1 x Battery pack for the micro:bit (optional)
What is an LED?
An LED or Light Emitting Diode is a semiconductor light source that emits (gives off) light when current flows through it.
An LED has a longer leg called the anode (+) and a shorter leg called the cathode (-) as shown above.
Creating the Circuit
Place the bit of cardboard on the desk
Take the red LED and bend the legs out to the sides. Place the LED on the cardboard with the longer leg to the right.
Take a bit of copper tape or glue and some aluminium foil over the long leg of the red LED
Complete steps 2 and 3 for the yellow and green LEDs.
Take a longer bit of copper tape or foil and tape/glue all three of the short legs of the LEDs together.
Connecting to the micro:bit
Take one of the crocodile/alligator leads and clip one end to the long piece of copper tape/aluminium foil covering the short legs of the LEDs and clip the other end to the GND pin of the micro:bit.
Take another crocodile/alligator lead and clip one end to the copper tape/aluminium foil of the longer leg of the red LED and attach the other end to pin 0 on the micro:bit.
Take another crocodile/alligator lead and clip one end to the copper tape/aluminium foil of the longer leg of the yellow LED and attach the other end to pin 1 on the micro:bit.
Take the last crocodile/alligator lead and clip one end to the copper tape/aluminium foil of the longer leg of the green LED and attach the other end to pin 2 on the micro:bit.
We are now ready to code our traffic lights
Coding The Traffic Lights
Within your favourite browser (we recommend Google Chrome) go to python.microbit.org and press Enter . This will load the Python coding editor.
Delete the text on lines 6, 7, & 8 .
Type the following code:
Now that we have completed the code we need to download it to our micro:bit
Downloading the Code
Connect the micro:bit to the computer using the micro USB cable.
Click on Connect . Click on your micro:bit and click Connect .
Click on Download .
Now that our code is downloaded to the micro:bit we will see the LEDs blink in a traffic light sequence.
Go back to your code and see what other patterns you can make the LEDs blink in.