14. Case 12: Birds Anti-Collision Device#

14.1. Introduction#

  • Bird hitting buildings or bird hitting glass refers to the fact that birds cannot recognize the existence of glass due to the transparent and reflective properties of the glass, and thus collide with buildings, especially glass windows, causing the birds to be injured or killed. Bird hitting buildings is one of the most serious threats to birds. One of the preventive measures is to turn off unnecessary lights or draw curtains at night. Because at night, the decorative light near the glass can disorient the migrating birds, causing them to collide with skyscrapers, office buildings or other glass decorated with lights. So we can design a device that automatically draws the curtains to reduce light interference.

14.2. Function#

  • Detect the light intensity with the light sensor on the micro:bit, if the light intensity is below the threshold, program to drive the servo to draw the curtains.

14.4. Picture#


14.5. Hardware Connection#

Connect the servo to P1 on IoT:bit.


14.6. Software Programming#

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


For programming, we need to add a package: click “Extensions” at the bottom of the MakeCode drawer and search with “servo” 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.

14.7. Program#

In forever block, judge if the current light level is below 20.


If yes, program to set the servo connecting to P1 to drive to 180°; or to drive to 0°.


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

14.8. Result#

  • If the light level is below the threshold, the servo drives to draw the curtains.