Microbit RGB LED Tutorial
In this tutorial we will show you how to wire and code an RGB LED using the Microbit. This is a great cheap Microbit project that teachers can do with their students, and it’s also very educational! It teachers the basics of wiring up external outputs, as well as how RGB colours are made.
You will need:
Wiring Diagram
Wiring up the LED is nice is nice and simple. Each of the outputs run from the Microbit, through a 100 ohm resistor and on to LED.
Wiring Example
Test code 1 – 3 alternative colours
The simplest way to test if your setup is working is to simply turn each output on one by one.
Test code 2 – composite colour
What about combining colors? Well, this is where the RGB comes in to play.
A simple example is Red + Blue , which makes a purpley pink colour.
Here we simply turn 2 outputs on at the same time!
RGB Color Generator
RGB colors are generated by a mix of three elements, with the brightness of each(luminosity) varying from 0 to 100%.
Have a go at moving the sliders below to see what colours you can generate.
Microbit RGB LED Tutorial Challenges
Challenge 1 – Traffic Light LED
Write a script that mimics the functioning of a traffic light, triggered when you press a button on the Microbit.
Challenge 2 – Random colour LED
Write a script that outputs a random colour from the LED
Challenge 3 – Pulsing LED
Write a script that allows the LED to pulse on and off
Challenge 4 – Blended colours
Write a script that blends slowly from one green to blue and back again.