BBC micro:bit
Bi-Colour & Tri-Colour LEDs

Introduction

Standard LEDs are diodes that light up when we push the right volts through its positive end. The negative end is always connected to ground to complete our circuit. We connect a resistor on at least one of these pins to limit the current through the diode (to stop our LED from popping) and to ensure the right voltage drop for our LED.

Bi-Colour LEDs are different. They look pretty much the same from the outside but the package contains two LEDs, connect in opposite directions. That means that when you drive one pin high, you turn the LED on by driving the other one low. If you do the reverse, you light the second LED. Flick quickly between the two and you see a filthy mixture of the two LEDs.

Tri-Colour LEDs have 3 pins and two LEDs. The difference is that one of the pins is a ground that is common to both LEDs. The other pins are the positive pins of the LEDs. Either or both of these can be driven high to turn the LEDs on. The blend is slightly improved on the bi-colour LED and allows for both colours to be off.

Circuit

Both types of LED are shown here. For the bi-colour LED, you only need to put a resistor on one of the legs. For the tri-colour LED, you need a resistor for each of the colours.

micro:bit Code

Programming

It's the same principle in code for programming both types of LED. This first program blinks the two colours.

micro:bit Code

This program allows the user to change the colours by pressing butttons A and B on the micro:bit.

micro:bit Code

This program flicks between the two LEDs, making it look like they are both on.

micro:bit Code

Challenges

  1. These kinds of LEDs are good to use on spare pins for mood lights or for funky buzzer and light shows.
  2. The red-green combo is good to use as a stop-go indicator for a game that needs the user to pause or for a project where you need a two state indicator.
  3. You can use a NOT gate with the tri-colour LEDs to have only one pin to control them. You lose the ability to turn both LEDs off but can reduce the number of pins you need.