Lesson 11 Rainbow LED


8 RGB Rainbow LED Ring is based on ws2812b LEDs. Its biggest characteristic is single IO control and infinite cascade connection. In this experiment, we are going to use micro:bit to drive 8 RGB Rainbow LED Ring and create rainbow color gradual change.

Component List

  • micro:bit board
  • Micro USB Cable
  • micro:bit breadboard adaptor
  • Breadboard
  • 8 RGB Rainbow LED ring
  • Male to male jumper wires

8 RGB Rainbow LED Ring

8 RGB Rainbow LED Ring is an LED ring made of 8 ws2812b LEDs in cascade connection. Ws2812b is an intelligent outer control LED source, which has integrated control circuit and light emitting circuit. It has same appearance with 5050 LED.

The digital protocol adopts communication method of single line goes to zero. After pixel point restoration, DIN will receive the data sent from the controller. Once the first 24-bit data received was extracted by the first pixel point, it will be sent to the internal digital lock storage device of pixel point and the rest data amplified through the inner transformation processing circuit will be sent to the next pixel point from DO port. Every time it passes through a pixel point transmission, the signal will decrease 24bit. The pixel point uses automatic transformation forwarding technique, thus the pixel cascade connection quantity is not limited by signal transmission but the speed of transmission only.

LED has advantages of low voltage drive, energy-saving and environment protect, wide scattering angle, good consistency, ultra-long life, etc.. To integrate control circuit onto LED, the circuit will become more simple, easier to install and have smaller volume.

Hardware Connection

Please complete the hardware connection according to the breadboard diagram below.

Note: There are two cables lead out by the ring. One is DI and the other is DO. We should connect DI.

After connecting the circuit, you should see:


Open Microsoft Makecode, write your code in the edit area.

In this experiment, we will add a package of code to enable us to use our 8 RGB Rainbow LED Ring. Click on Advanced in the Code Drawer to see more code section and look at the bottom of the Code Drawer for Add Package.

Of course, you can download the whole code from the link below.

Code Explanation

set to NeoPixel is used for initialize the bead. Among it, three parameters need to be set: “pin” is set to be the footer connect LED strip, “with x leds” set to be the quantity of LEDs, and “as RGB” to be the type of LED.

show rainbow

It is used to make the light of LED strip become rainbow color gradual change.


After we set the color of the LED, it will not start to work. To make it works, you have to use show.

sotate pixels

Make LED color move in circle.


We can see the light of 8 RGB Rainbow LED Ring is rotating with rainbow color.

Taking it further

Imagine the ring is a big eye, in order to make it twinkle, then how to design the circuit and program?

micro:bit Starter Kit Lessons

  • Lesson 01 – LED
  • Lesson 02 – Button
  • Lesson 03 – Trimpot
  • Lesson 04 – Photocell
  • Lesson 05 – RGB LED
  • Lesson 06 – Self-lock Switch
  • Lesson 07 – Temperature Sensor
  • Lesson 08 – Servo
  • Lesson 09 – Buzzer
  • Lesson 10 – Motor
  • Lesson 11 – Rainbow LED
  • Lesson 12 – Accelerometer
  • Lesson 13 – Compass
  • Lesson 14 – Ambient Light
First published at 4:02pm on July 9, 2019
Last updated at 4:02pm on July 9, 2019