## Introduction

You might have already tried your hands at making a two colour LED module blink with the micro:bit, but have you tried using an RGB LED module?Â

In this guide, you will learn to make an RGB LED blink and change to a variety of colours.Â

Complete this guide to learn the basics of programming an RGB LED!

If you're using the Micro:bit Advent Calendar, you'll need the contents of the bags labelled 2 and 25.

1. ## Step 1 The Module

• Let's take a look a closer look at the RGB LED Module before we begin. There are four pins:

RED (R)

GREEN (G)

BLUE (B)

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.

• As you might guess, this module is capable of emitting red, green, blue as well as a variety of colours based on how they are combined. This module has on-board resistors, so external resistors are not required here.Â

3. ## Step 3 Insert the Micro:bit into the Breakout board

• 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.

8. ## Step 8 Start Makecode Editor

• Now let's program it with the Makecode Editor.Â

• Click on 'Projects' button

• Click on 'New Project'

9. ## Step 9 The MakeCode

``````basic.forever(function () {
pins.digitalWritePin(DigitalPin.P0, 1)
basic.pause(500)
pins.digitalWritePin(DigitalPin.P0, 0)
basic.pause(500)
pins.digitalWritePin(DigitalPin.P1, 1)
basic.pause(500)
pins.digitalWritePin(DigitalPin.P1, 0)
basic.pause(500)
pins.digitalWritePin(DigitalPin.P2, 1)
basic.pause(500)
pins.digitalWritePin(DigitalPin.P2, 0)
basic.pause(500)
})
``````
• Copy and paste this code into the Javascript blocks interface.

10. ## Step 10 Turn on more than one colour at a time

``````basic.forever(function () {
pins.digitalWritePin(DigitalPin.P0, 1)
basic.pause(500)
pins.digitalWritePin(DigitalPin.P1, 1)
basic.pause(500)
pins.digitalWritePin(DigitalPin.P1, 0)
basic.pause(500)
pins.digitalWritePin(DigitalPin.P2, 1)
basic.pause(500)
pins.digitalWritePin(DigitalPin.P2, 0)
basic.pause(500)
})
``````
• You can turn on more than one of the colours at the same time. When this happens, the overall colour of the LED will be a blend of the RGB LED colours. Let's try that out and find out what colours you get for each combination!
Copy and paste this code into the Javascript blocks interface.

• Give it a try, test out these combinations yourself:

• RED + GREEN
• RED + BLUE
• GREEN + BLUE
• RED + GREEN + BLUE

11. ## Step 11 Upload the code to micro:bit

• 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.