Case 09: Noise Detection Device in the Library
10. Case 09: Noise Detection Device in the Library#
Noise has always been a serious problem in library management. If you stay in an environment above 85db for more than 8 hours, it will damage the hearing ability, although under normal circumstances the library will not have such a large source of noise , but the impact to readers from smaller noise cannot be ignored in the library . Thus, we can make a library noise detection device to remind people of the current environmental noise level.
Detect the noise level from the sound sensor on the micro:bit and have the value displayed on the OLED screen, program to light on the LED with the equivalent color.
10.5. Hardware Connection#
Connect the green led to P1, the yellow to P2, the red to P9 and the OLED to the IIC port on IoT:bit.
10.6. Software Program#
Click “Advanced” in the MakeCode drawer to see more choices.
For programming, we need to add a package: click “Extensions” at the bottom of the MakeCode drawer and search with “iot-environment-kit” in the dialogue box to download it.
Notice: If you met a tip indicating that some codebases would be deleted due to incompatibility, you may continue as the tips say or create a new project in the menu.
Initialize the OLED and display the sound level on the OLED screen.
If the sound level is below 100, program to light on the green led, if it’s below 150, program to light on the yellow led; or to light on the red led.
Different LEDs are lightened in accordance with the equivalent sound level.