6. Case 04: The Birds Nest#

6.1. Introduction#


The human activities have changed a lot on the living environment of birds, the birds are not easy to find places to rest and food in cities, therefore, we could make a bird nest for them to live.

6.2. Function#


Control the lighting of LEDs in different colors from the tilted status of the micro:bit to remind people of protecting the nests.

6.4. Picture#


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

6.5. Hardware Connection#


Connect the green LED to P1, the yellow to P2 and the red to P9 on IoT:bit.

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

6.6. Software Programming#


Click “Advanced” in the MakeCode 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.

6.7. Program#


Turn on the lights in accordance with the micro:bit status, if the micro:bit logo faces upwards it means the nest is in a normal status with the green led turnning on; if the yellow led lights on, it means the micro:bit is in a tilted status which means the nest is tilting to the left/right side; or the red means the nest is upside down now and it requires a re-construction.

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

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

6.8. Result#


  • The nest is in a normal status if the green led is turnning on; if the yellow led lights on, it means the micro:bit is in a tilted status which means the nest is tilting to the left/right side; or the red means the nest is upside down now and it requires a re-construction.