Lesson 8 - Automatic Quantitative Feeder

Lesson 8: Automatic Quantitative Feeder

In this final lesson, students solve a real problem on the farm. They teach the AI camera the animals that should be fed, then build a feeder whose tray tilts to drop one set portion of feed—but only when one of those animals comes. Any other animal gets nothing.

image1.png I can connect the hardware and build the automatic feeder with the bricks.

image1.png I can teach the AI camera to recognize the animals that should be fed.

image1.png I can modify the program so the feeder drops one portion of feed only when a taught animal appears.


 

1. Engage: The Feed Keeps Getting Stolen

On the farm, the cows and the sheep must be fed at set times and in set amounts. But the moment the feeder is left open, dogs and wild birds rush in and eat everything. The feed runs out fast, money is wasted, and the cows and the sheep go hungry. The farmer wants a smart feeder: it should drop feed only when the animals that need feeding come close—and do nothing for any other animal.

image2.png

Key Question

How can the feeder give feed only to the animals we want to feed, and not to any other animal?

 

People can tell the animals they want to feed at a glance. Can a camera learn to recognize them too? Let's use the self-learning mode and find out.

 

2. Explore: Build the Feeder and Teach the Animals

Activity 1

Make the hardware connection:

image3.png

Build the automatic feeder with the bricks following the Building Instruction.

image4.png

Press the mode button to switch the camera to self-learning mode.

Build a card stand so every card is held steadily and fully in view of the camera.

Here is a sample you can refer to:

image5.png

Activity 2

Find the cow card and the sheep card and teach both to the camera one at a time, checking the white light before moving on.

By now, students should be able to explain that the camera can distinguish the animals we want to feed from everything else.

Teacher note: Make sure students understand that the camera only recognizes what it has been taught. If needed, ask what happens with an animal it has never seen.


 

3. Engineer: Build the Automatic Feeder

Modify the Code

1. Open MakeCode and import barnyard-8-1.

image6.png

Project Link

2. Change the servo angle so the tray tilts far enough to drop the feed out.

image7.png

Teacher Note: Remove the tray during code testing so it does not hit the other bricks, then put it back once the program runs correctly. Use the connector pins as pretend feed so students can see and count each portion the tray drops.

3. Download the program and test the effect.


 

4. Experience & Challenge: Feed the Right Amount

Experience: tune the portion

Activity 3

Change the servo angle and test which angle drops one portion of feed best—not too much, not too little.

image9.png

Try adding a buzzer or an LED matrix as a “feeding” signal.

Here is the sample code:

image10.png

Project Link

 

Challenge: daily quota

 

Key Question

The feeder drops one portion each time it sees an animal. How can we stop it from feeding the animals all day long?

 

Activity 4

Import the program barnyard-8-2. It already uses a variable to count the portions the feeder has dropped.

image11.png

Project Link

Look at the count, then add a check: when the count reaches the limit (for example, 5), the feeder does not drop feed even if it sees a cow or a sheep.

image12.png

Download the program and test it: feed the animals until the limit is reached, then confirm the feeder does not feed them again.

Here is the sample code:

image13.png

Project Link


 

5. See More: Trained by Examples

Show the camera pictures of other breeds of cows and sheep—a brown cow, a black-nose sheep.

Breed picture 
image14.pngimage15.png

Key Question

They are all cows and sheep. Why does the AI camera ignore some of them?

The camera does not know "cow" or "sheep" the way you do. It only knows what it has seen before. It learned from a few examples, so it recognizes animals that look like those examples. A different colour, pattern, or shape can look new to it.

Think of a picture book: if your book only has black-and-white cows, a brown cow might look strange to you at first.

 

Data and bias

If the data is not diverse, the AI only works for a few cases.

If the data is not balanced, the AI may work well for one kind of animal and poorly for another.

A bias in the data becomes a bias in the AI. On a real farm, some cows or sheep might never get fed.

 

All Lessons

icon Lesson 8.zip 4.74MB Download(1)
License
All Rights
Reserved
licensBg
0