Colorful LED Strip | Boson starter for micro:bit 09

0 3629 Easy
projectImage
projectImage
projectImage
projectImage

STEP1: Connect the LED strip to pin P0 of the expansion board.

projectImage

STEP2: Add the LED strip command module. Click Expansions->Display->WS2812 RGB LED Strip, then back to the former interface.

projectImage

STEP3: Programming

1. Click “display” module in the left to present the LED strip commands.

projectImage

2. The pin P0 connected to the LED strip comes with 7 LEDs. Set the color range to 01-360 to realize a rainbow effect display (red-green-blue).

projectImage
projectImage

1. If we want to make the LEDs turn on in a sequence, we need to use a new module: Variables.

projectImage

To set such a variable, go to: “Variables-> Make a Numeric Variable”, and set the name of the variable (to be clear, we named the variable as “the number of LEDs to be lit”). Then click OK.

projectImage

2. Initialize the pin and total number of the LED, and set the brightness. The initial value of the variable “the number of LEDs to be lit” (αfor short) should be set to 0(since all the LEDs are turned off at first).

projectImage

3. When α≤6,α LEDs to be lit, then maintain 1 second, and make the parameter getting larger by 1 in every loop. If α>6, make all the LEDs turn off and start from the beginning. The flow chart below may help us to figure out what the program looks like:

projectImage

4. Programming according to the flow chart, first setting the conditions, we need to use “if…then…else” and “forever” blocks.

projectImage

5. If “the number of LEDs to be lit”(α) is less than 6, light upαLEDs, wait 1 second, then make the parameter getting larger by 1, which means to make one more LED light up.

projectImage

6. When the number of LEDs to be lit is over 6, set the value of “the number of LEDs to be lit” to 0, and turn off all the LEDs.

projectImage
projectImage
projectImage

STEP1: The LED strip still connected to P0; connect the sound sensor to pin P1.

projectImage

STEP2: Click “micro: bit” module, drag the “read analog pin P0” block to script area, and revise P0 to P1.

projectImage

STEP3: If the sound value the sensor detected exceeds 40 and the “the number of LEDs to be lit” αis less than 6, control the LED strip to light upαLEDs. Then the sensor will be constantly detecting the sound value.

projectImage

STEP4: Programming

Based on the program of the last project, we need to add a “if…then” statement to judge the sound value. That is to say, when “the number of LEDs to be lit”α≤6,if the analog pin P1 is over 40, thenαLEDs will be turned on, wait 1 second, changeαby 1, and repeatedly to detect if the sound value exceeds 40. When “the number of LEDs to be lit”α>6, all the LEDs will be turned off and start the program from the beginning.

projectImage
projectImage
License
All Rights
Reserved
licensBg
0