Cover image
    Activity

    Code a micro:bit to Make a Rainbow

    Create the rainbow iterating over hues.

    Coding
    Get Started
    8-14+
    40:00
    micro:bit Coding Cards

    Code

    Rainbow

    00:10

    Smoothly change the RGB LED A color, by iterating over different hue values from 0 to 100.

    basic.forever(function () {
        for (let index = 0; index <= 100; index++) {
            sb.setRgbLedColorHSB(sb.rgbLed(SBRgbLed.RgbLedA), index, 100, 100)
            basic.pause(100)
        }
    })

    If using micro:bit for the first time, follow this setup.