RGB Color matching Game

Have a go at this RGB Color matching game.

Color Matching Game

Introduction to RGB LEDs

An RGB LED is a special kind of led that contains three mini leds inside itself! 1 Red, 1 Green, 1 Blue.

Because it contains all three LEDs and each LED can be turned on/off off separately, you can combine colours to make different colours.

Also, because you can vary how bright each LED is, you can make any color whatsoever!



Notice the flat edge of the RGB LED is at the top!

RGB LED connections fixed


Digital Colors ( On or Off)

We can turn the individual lights on and off, and combining them means that we can create up to 8 colors!

Red Green Blue Ouput
off off off Black(off)
on off off Red
off on off Green
off off on Blue
on on off Yellow
off on on Cyan (Turquiose)
on off on Magenta ( Purple)
on on on White

Take a look at the demo code to see for yourself!

Python Code

Calculating Color values

Google RGB Colors

Digital Vs Analogue Output

Turning the LEDs fully on or off will only get using a limited number of colors:

Red, Green, Blue, White, Black, Cyan,Magenta,Yellow

If we want to make ANY color, we need to use analogue value -this means that we need control the brightness of each LED. The Microbit allows you to set a brightness value of between 0 and 1023, but RGB colors only have individual channel values of between 0 and 255. So how do we fix this? We simply multiple the value by 4 and we have our Microbit analogue value!

Example – Baby Pink

Red Green Blue
RGB Value 255 155 255
Microbit Value 1020 620 1020

Python Code

JavaScript Code Kingdoms Blocks Example

Can you guess what this code will do?

alternating leds RGB led digital microbit

Python Code

This code is design to blend from red to blue on a gradient!

microbit red to blue gradient python code

Challenge 1  – Alernative LEDs

Get the RGB LED to alternate between red, green and blue LEDs




Challenge 2 – Traffic Light LEDs

Get the Microbit to emulate(copy) the functioning of a traffic light!




Challenge 3 – Orange / Purple alternator

Get the RGB Led to alternative between Orange and Purple



Challenge 4 – Rainbow RGB LED

Get the RGB LED to go through all the colours of the rainbow



Challenge 5 – Fade from White to off

Get the RGB LED to fade from fully on (white) to fully off



Challenge 5 – Fade from Green to Blue

Get the Microbit to fade from green to blue