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.2. Hardware Connect


../../_images/zm91HVe.png

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

12.3. Principles of Circuits


../../_images/plRaylG.png

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

12.4. 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).

../../_images/vCBPKXo.png

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

12.5. Software


Step 1

../../_images/t34k5Zb.png

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

../../_images/Zg0fO6x.png

  • Search “neopixel” and add the neopixel.

../../_images/pqB776X.png

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.

../../_images/aamdVlu.png

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.

../../_images/5juGvN5.png

Program

---

12.6. Result


  • We can see a rainbow rotates on the LED ring.

  • ../../_images/23vhDKK1.gif

12.7. Think


  • How can we make the ring blink like an eye?

12.8. Questions


12.9. More Information