Goal


Materials


Background


What is voice-activated lights

Practical operation


Materials: corrugated board and cutter

Build as below picture:

Paste devices as below piture:

Hardware connect


Connect one Rainbow LED to P1 of sensorbit.

Connect sound detect device to P2.

Connect light sensor to P3.

Software


makecode

Edge Connector Data Sheet

We will use P3, but firstly we need disable the LED Array because it also use P3.

Programming


Step 1

Go to MakeCode page, click Advanced in the code block and click on Extensions.

We need to add a new codebase for programming of smart home. Finding “Add Package” in the bottom of code block and click it. Then a message box will show up, search “smart home”, and download this new codebase.

Note:If there is a hint says some codebase will be deleted because of incompatibility. Don’t worry. You could go ahead as the hint or build a new item in item menu bar.

Step 2

Drag forever block from Basic, drag show number block and it snaps into forever.

Drag led enable block from LED ,choose false for disabling the LED Array.

Step 3

Snap “set light to value of light intensity (0~100) at pin P3” into forever block and change the number after light to 50.

If the value of light intensity more than 50, it is during the day.If the value of light intensity less than 50,it is during the night.

Step 4

Snap “set noise to vlaue of noise (dB) at pin P2” while the value of light intensity less than 50. Change the number after noise to 70.

Sensor voice by Judging value of noise greater than 70.

Step 5

The Rainbow LED shows white light when it sensor value of noise greater than 70 and off after 10 seconds.

Programming

Make code:https://makecode.microbit.org/_TayEPHhtsPqo

You also could directly download program visit website as below:


Note: The value of light intensity is base on actual environment.

Result


The light will never up when illumination is adequatea. However,slight noise will cause it light 10 seconds during the night.

Think


How to use micro:bit make rainbow Led rather solid color light?

Questions


More information