13. Case 12: Birds Anti-Collision Device¶
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.
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.
13.5. Hardware Connection¶
Connect the servo to P1 on IoT:bit.
13.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.
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°.
If the light level is below the threshold, the servo drives to draw the curtains.