13. Case 11: Smart Lamps for Basketball Courts#

13.1. Introduction#


  • In the city, there are places for citizens to exercise, such as basketball courts. Whenever it is night, the basketball court will always turn on the lights, thus, we can make a smart lighting that will automatically turn on the lights when it detects that someone is moving on the basketball court, otherwise it will automatically turn off the lights.

13.2. Function#


  • Light on the lamps if there are people on the basketball courts and turn off the lamps if there is no one there.

13.4. Picture#


../../_images/microbit-Smart-City-Kit-case-01-02.png

13.5. Hardware Connection#


Connect the yellow led to P1 port on IoT:bit.

../../_images/microbit-Smart-City-Kit-case-07-03.png

13.6. Software Program#


Click “Advanced” in the MakeCode drawer to see more choices.

../../_images/microbit-Smart-City-Kit-case-01-04.png

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.

../../_images/microbit-Smart-City-Kit-case-01-05.png

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.

13.7. Program#


Judge the sound level, if the value is over the threshold, program to light on the LED; or program to turn off it.

../../_images/microbit-Smart-City-Kit-case-11-07.png

Link: https://makecode.microbit.org/_VrMF7Da1uAib

13.8. Result#


  • If the sound level is over the threshold, it means there are people on the courts, program to light on the leds; or program to turn off the lights.