3.22 Voice Control Light
3.22.1 Overview
Voice-control-light device mainly consists of a sound sensor, a photoresistor and an LED. The photoresistor is adopted to avoid LED lighting up during daytime. The sound sensor measures sound volume to determine whether it is reached the set threshold. If yes, the LED will light up for a few seconds.
3.22.2 Test Code
3.22.2.1 Code Flow

3.22.2.2 Build Code
There are two ways to upload the code: directly open the code file we provide; or manually build blocks.
Directly open the code file we provide:
Click
and choose Load from your computer

We have already downloaded the codes on computer desktop, so open the file and choose
3-22-hallwayLight.sb3
Manually build blocks:
Build the two basic blocks:

Drag
to determine the photoresistor value. If it is lower than 500 (light < 500), execute its following code blocks.

Add a
again to determine the sound sensor value. If the value is greater than 200 (sound > 200), execute its following code blocks.

When sound > 200, red LED lights up and then goes off after 5 seconds.

Complete Test Code

3.22.2.3 Test Result
After uploading code, the LED never lights up no matter how loud the noise you make. Cover the photoresistor, and make some sounds, and you will see the LED light up for 5 seconds.