Microbit Halo Programmable Expansion Board Tutorial 1.3 Light a color randomly (download)
The data protocol of the programmable RGB lamp adopts the single-line return-to-zero code communication mode. After the power-on reset, the DIN terminal accepts the data transmitted from the controller. The first 24 bits of data sent by the first pixel are extracted, the data latch is sent to the inside of the pixel. And the remaining data is shaped and amplified by the internal shaping processing circuit, then the output is forwarded to the next cascaded pixel by the DO port.
If the programmable RGB lamp is fully lit, the battery is not enough voltage, it will affect the effect,such as color saturation of RGB lamp is reduced or microphone not work normally.
It is recommended to use the USB data cable to plug in the RGB LED Circular expansion board interface. As shown in the figure below.
2. Learning goals:
In this lesson we will learn how to realize that the RGB LED Circular randomly displays a color after turning on the power. If you want to change color, press the reset button to reset the program and display a random color again.
If some of the RGB LED Circular is not lit or the color is wrong, it may be due to insufficient power supply. Please turn down the brightness of the light or plug the USB data cable into the RGB LED Circular expansion board interface.
3. Programming method:
First,we need to connect the micro:bit to the computer by USB data cable, the computer will pop up a USB flash drive.Then, click on the URL in the USB flash drive: http://microbit.org/ to enter the edit process interface.
Open the offline programming software,download address of this software: http://www.microbitgo.com/code.
After creating a new project, you need to load the Neopixel library to program the programmable RGB lights. To load the library, click on 【Advanced】—【Extensions】 — click on 【Neopixel】, and you will see an extra column in the programming interface. As shown in the figure below.
General program diagram:
Our programmable RGB lamp is connected to the pin2 of micro:bit, so the pin2 is set to no pull-up/pull-down mode by default. Then use the following statement to create a new NeoPixel driver named Strip.
Next, we need to set the strip to randomly display a color.
We need to make sure that the micro:bit board is connected to the computer. Click the download in the lower left corner as shown below, and select the download path as micro:bit drive letter to download the program.
After the program is successfully downloaded, you can see that the RGB LED Circular expansion board display a color randomly.
- Last Tutorial>> Microbit Halo Programmable Expansion Board Tutorial 1.2 Three primary colors
- Next Tutorial>> Microbit Halo Programmable Expansion Board Tutorial 1.4 Breathing light