Lesson 7 - Bird-Repelling Scarecrow
Students apply the self-learning mode to a real farm problem. They teach the camera to recognize a bird, then build a scarecrow that swings and buzzes whenever a bird appears.
I can teach the camera to recognize a bird.
I can build a scarecrow that swings when a bird is detected.
I can use an if inside a loop to control when the scarecrow acts.
1. Engage: The Birds Are Eating the Crops
Birds keep landing on the farm and eating the crops. A scarecrow that moves all the time wastes power, and after a while the birds ignore it. We need a scarecrow that acts only when a bird comes.

Key Question
How can the scarecrow scare the birds away only when a bird appears?
The AI camera can recognize birds: when a bird is seen, move the scarecrow and sound the buzzer; when there is no bird, stay still.
2. Explore: Build the Scarecrow and Teach the Bird Card
Activity 1
• Make the hardware connection:

• Build and install the hardware following the Building Instruction:

• Install the scarecrow on the servo arm so the servo can swing it.
• Press the mode button to switch the camera to self-learning mode.
• Teach the camera the bird card: press the learn button, then wait for the white light to fast-blink.
• Test it: show the bird card — the camera recognizes it (the white light stays on). Show a different card — nothing happens.
Teacher note: guide students to build a card stand, just like in Lesson 6; check the white light before moving on to the program.
Here is a sample you can refer to:

3. Engineer: Build the Smart Scarecrow
Build the Code
Open MakeCode and add the required Extensions.
| Click Extensions | |
| Search “https://github.com/DFRobot/pxt-Building-Block-Expansion-Board-for-microbit-UNIHIKER.git” | |
![]() | Add the extension |
| Type boson and search | |
![]() | Click the extension and go back to the coding page |
Build the program.

Download the program and check the effect.
Teaching note: the if checks for a bird; the repeat loop swings the scarecrow several times; the servo returns to rest when no bird is there.
4. Experience & Challenge: Make the Scarecrow Smarter
Experience: tune the scarecrow
Activity 2
• Change the servo angles and the number of swings (the repeat count), and add the buzzer effect.


• Test which settings scare the birds best.
Challenge: Confirm Before Scaring
Key Question
How can the scarecrow tell a real bird from a single false reading?
Activity 3
• Add a confirmation counter so the scarecrow acts only after the bird is seen for 5 consecutive checks.
• Build the program as follows:

• Test: flash the bird card briefly and confirm nothing happens; hold it steady in view and confirm the scarecrow acts.
Teacher note: the reset (set count to 0) is what makes the checks consecutive. Ask students what happens if the reset to 0 is removed. Students who finish early can change the threshold.
5. See More: AI Eyes on the Farm
Key Question
How do farms use AI cameras to grow better crops?
Our scarecrow is a small example of a big idea. Farms around the world use AI cameras — “AI eyes” — to help them grow better crops.
Here are some ways real farms use AI vision:
| What it does | How the camera helps |
| Spot weeding | The camera tells a weed from a crop, so a machine sprays only the weeds — and uses less pesticide. |
| Disease watch | The camera finds sick leaves or pests early, before they spread. |
| Fruit counting | Cameras count the fruit on the trees to predict the harvest. |
| Livestock care | Cameras count the animals and watch their health. |
| Animal deterrence | Vision-triggered devices scare birds and other animals away — the real-world cousin of our scarecrow. |
They all work like our scarecrow: the camera sees, the program decides, and something acts — see, decide, act.
Next lesson: Lesson 8











