12. case 10 rainbow led ring#

12.1. Introduction#

The RGB Rainbow LED Ring is made of 8 ws2818b pixels in a cascade connection. Its most notable characteristic is single IO control and infinite cascade. In this case, we will drive the RGB Rainbow LED with the micro:bit to make the rainbow colours rotate around the ring.

12.3. Hardware Connect#


Connect circuit as above picture and put 2 AAA batteries into batteries pack.

12.4. Principles of Circuits#


The GND of slot on micro:bit is into innards of batteries’ GND to generate the current loop.

12.5. Introduction of Components#

RGB Rainbow LED Ring(8 LEDs)#

The RGB Rainbow LED Ring is made of 8 ws2812b pixels in a cascade connection. Each ws2812b is made of an integrated control circuit and a RGB chip. The first pixel receives 24bits of data through the DIN (Data IN) port, while the rest of the data is sent to the following pixels through the DOUT (Data OUT) port. With this automatic transformation forwarding technique, only the speed of data transmission is affected, not the quantity of data transmitted. The experiment box included a set of RGB Rainbow LED(8 LEDs).


Note: Please note the positive and the negative when you are connecting.

12.6. Software#

Step 1#

Click makecode https://makecode.microbit.org/#

Click on “New Project” and set a new Project.


Click Advanced for more code blocks and find the Extensions at the bottom of the column.


Search “neopixel” and add the neopixel.


Step 2#

Under the on start block, initialize the LED, set pin to P0 with 8 LEDs and use the RGB colour. Then, set the rainbow from 1 to 360.


Step 3#

Now the colour of the LED has been set, but we need a show block to make it works. Next, set rotate pixels to rotate the colour of the LED in a ring.



Program link:https://makecode.microbit.org/_LJAe7W97fDat

You also could directly download program by visiting website as below:

12.7. Result#

We can see a rainbow rotates on the LED ring. ../../_images/23vhDKK1.gif

12.8. Think#

How can we make the ring blink like an eye?

12.9. Questions#

12.10. More Information#