10 – Lunch Break

You have a lot of animals in the robot zoo. How are you going to keep them all fed??
Let’s make a feeder, so the animals can get their own food. When they’re hungry, they just pull the green lever on the front and the machine will give them their meal.

Click here for the instructions

Write a program now. Every time the motion sensor is tipped, move the motor at speed 1 forward for 0.1 seconds. But limit it to 6 times, because then the food runs our and the motor jams.
Make another line of blocks that reverses the feeder so you can reload it. Move the motor at speed 5 for 1.4 seconds.

Click here if you need the solution

WAIT!

What if the animals pull the lever and eat all the food at once? You’ll have a bunch of sick zoo animals. And lots of animal poop.
Add something to make sure the animals have to wait 30 seconds before pulling the lever again. No hints! You can figure it out!

Automatic Feeder

We can make the feeder reverse itself for re-loading automatically using variables! Remember those envelopes with messages in them?
This program sends a message from the sensor which is either zero or nine when it is fully tipped.
None of the lines of blocks has zero for a starting number, so zero means “just wait.”
If the lever is pulled, the variable is set to 9. The message of 9 starts the second line which advances the feeder.
That also subtracts one from the number on the screen. At the end of the second line, it sends the number on the screen to the variable.
When that number gets to 1, it reverses automatically!
This is pretty fancy stuff, so follow it through block by block and you’ll be a real pro!