1. Color mixing
  2. RGB LED - description and types
  3. Color mixing program


  1. Color mixing

One can display a certain color by mixing only three basic colors: Red, Green and Blue. Adding different levels of each color we get many colors.

If all colors are OFF, we get black, and if colors are fully ON, we get white. You can find many color mixing web sites to understand better and to play with different percentages of colors (for example: https://www.colortools.net/color_mixer.html).




An RGB LED is made of three LEDs: a red one, a blue one and a green one.
Some RGB LEDs have the anode terminal (or "+" terminal) in common and some have the cathode terminal (or "-" terminal) in common.


The one we are going to use in our project is a Common Cathode RGB LED.




Micro:bit pinsRGB LED pins
0Red (via resistor)
1Green (via resistor)
2Blue (via resistor)
GNDCommon Cathode

Like with all LEDs we are going to use a resistor (220 Ohms, in our case) in series in order to limit the current, thus protecting the LED and the micro:bit.

3. Program


  • pressing button B will switch between colors. Also the initial of the color will be displayed (“R” or “G” or “B”);
  • pressing button A will increase the quantity of the color selected at the previous step. The quantity will be visually displayed on the LED matrix (using the “plot bar graph” block). The values are between 0 and 100;
  • microbit can generate 1024 steps of color (from 0 to 1023). Our program will only generate 1000 steps of color, by multiplying each value selected by the A button with 10 and writing this value to the pins that are connected to the LED color pins. Of course we can choose different values if we want the colors to increase quicker or slower.