16. Rainbow LED Ring¶
Rainbow LED Ring is based on WS2812B bead that can show the RGB.
Designed in RJ11 connections, easy to plug.
|Type of Connection||Digital input|
|Core IC||WS2812 3535 Encapsulation|
|Number of Pixels||8|
16.5. Quick to Start¶
Materials Required and Diagram¶
Connect the Rainbow LED ring to J1 port in the Nezha expansion board as the picture shows.
16.6. MakeCode Programming¶
Click “Advanced” in the MakeCode drawer to see more choices.
We need to add a package for programming, . Click “Extensions” in the bottom of the drawer and search with “PlanetX” in the dialogue box to download it.
Note: If you met a tip indicating that the codebase will be deleted due to incompatibility, you may continue as the tips say or build a new project in the menu.
Code as below:¶
Rainbow LED ring lights on.
16.7. Python Programming¶
from microbit import * import neopixel from enum import * from random import randint np = neopixel.NeoPixel(J1, 8) while True: for pixel_id in range(0, len(np)): red = randint(0, 60) green = randint(0, 60) blue = randint(0, 60) np[pixel_id] = (red, green, blue) np.show() sleep(100)
Rainbow LED ring lights on after powering on.