$USD
  • EUR€
  • £GBP
  • $USD
PROJECTS micro:bit

micro:bit Project 8: Colorful Light Strip

DFRobot Oct 15 2018 1127

After the last lesson about the music box, have you found something more to be learned? Yes, in this lesson we will learn to make LED strip! Is it hard to wait? Let's get into the fantastic light world!

Components needed

Main control board of micro:bit
Expansion board of micro:bit
1× Rainbow LED strip
1× Sound sensor module
1× USB cable

Hardware Connection

Connect the RGB LED strip to the interface P0 of the expansion board


Program

Task1: light the rainbow LED strip

Functions: when the program is burned to the micro:bit, you can control the rainbow LED strip with 7 colors.

STEP1: usually there is no instruction collection about the rainbow LED strip in the instruction area. To control the LED strip, the Neopixel needs to be called which can be found at the lowest part of the instruction area. Click "Add Package" and there appears the menu bar of it. The procedure for calling instruction: Advance ---- add package ---- neopixel. Click on neopixel to add the neopixel module.


STEP2: usually, in the instructions controlling the rainbow LED strip, the pin of the micro:bit, the LED numbers and colors of the strip need to be decided first. The instruction needed here is as following: 

After this, the scope of the LEDs needs to be determined. The instruction needed here is as following: 

Then, the color ranges of the LED strip need to be decided. The instruction needed here is as following:  

The related instructions are as following: ( the parameters will be modified in use)


STEP3: The pin P0 connected the strip contains 7 small LED lights. Set the color range of the strip as 1-360 (red - green - blue) to produce 7 colors. After adjusting the parameters, the final program is finished.


Task2: Turn on the rainbow lights successively

Functions : when the program is burn to the board, you can control the LEDs by lightening each one of them by every one second to show colorful effects.

STEP1: the instruction to treat the variable is required for lightening each one of them by every one second to control the number of LEDs to be lit. The procedure for calling instructions: Variables ---- Make a Variable, arbitrarily set the variable name (such as: the number of LEDs to be lit), and then click OK.

STEP2: "the number of LEDs to be lit" (also referred to as "a") is initially set as the variable is 0 (initially there is no light lit), then increase 1 while controlling the variable, the looping statement is needed here. When the "the number of LEDs to be lit" is less than 7 the instructions needed are as following to light the LEDs continuously.

STEP3: When “the number of LEDs to be lit”(a) is less than 7, you can light (a) LEDs. After a delay of 1000ms, increase “the number of LEDs to be lit” to a+1. The flow chart is as following:

STEP4: "the number of LEDs to be lit" (also referred to as "a") is initially set as 0. When “the number of LEDs to be lit”(a) is no more than 7, you can light (a) LEDs. After a delay of 1000ms, increase “the number of LEDs to be lit” to a+1. Then keep the cycle until “the number of LEDs to be lit” > 7, all LEDs go out. Keep one LED is lit by every one second.


Task3; rainbow LED strip controlled by a sound sensor

Functions: The LED strip is off initially, when there is sound, a LED of the strip is lit. When there is no sound, the LED keeps off.

STEP1: in this task, a sound sensor is needed. When there is sound, the sound sensor can detect it and light the LEDs. We have learnt how to use the sound sensor before, let's review how to call instructions. The procedure for calling the instruction is: Pins(advance) – analog read pin (p0), change P0 to P1.

STEP2: When the sound intensity > 40 is detected by the sound sensor and the number of lighted LEDs does not exceed 7, one more LED will be lit. Then the sound sensor continuously detect whether the sound intensity exceeds 40 or No.
The flow chart:

STEP3:the final program

REVIEW