Want to make an LED light up and easily change their colours?

In this guide, we will learn to use a handy little LED module and make it blink using the micro:bit!

After completing this guide, you will understand how to use an LED and create a simple program using MakeCode. 

If you're using the Micro:bit Advent Calendar, you'll need the contents of the bags labelled 1 and 25.
    • Before we begin, let's take a closer look at the Two Colour LED module! There are three pins:

      Signal: This pin is a signal pin, and can be used to emit a green light

      Middle Pin : This pin is another signal pin, and can be used to emit a red light

      GND: Though it is labelled '-' on the module, this is the ground pin also known as 'GND'. What is 'GND'? In electronics, we define a point in a circuit to be a kind of zero volts or 0V reference point, on which to base all other voltage measurements. This point is called ground or GND.

    • Voltage is the difference in electric potential between two points. As it is difficult to talk about voltage without a reference point, we need another point to compare it to. 

    • You might have noticed an 'R1' on the module, this stands for 'resistor'. However, the resistor here is actually a 0Ω resistor,  so we will need to use external resistors in the circuit!

    • Insert the micro:bit into the breakout board.

    • Make sure that the micro:bit is inserted in the right orientation, with the buttons facing inward as shown.

  1. basic.forever(function () {
        pins.digitalWritePin(DigitalPin.P0, 1)
        pins.digitalWritePin(DigitalPin.P0, 0)
    • The first program we will create will make the LED module flash red. So open up the Makecode Editor.

    • Click on the Projects button

    • Create a new document

    • Copy and paste the Javascript code into the Javascript programming interface.

    • Click on the 'blocks' interface button and you should now see the MakeCode blocks.

    • Not unlike dragging a file into a USB drive, this is how you will upload the program to the micro:bit. So open up Finder on the MacOS or Explorer on Windows, and drag the hex file into MICROBIT under 'Devices' on the macOS.

    • Watch the micro:bit flash for a few seconds. Let the LED continue to flash until it is done, then unplug it.

    • Connect a microUSB cable to the micro USB port of the micro:bit

    • Then connect the other end of the cable to your computer or laptop's USB port

    • Click on the Download button on the bottom left-hand corner of the Makecode screen

    • Find the hex file in the Downloads folder or other folder that you might have moved it to