
Frog Feeder Electronics Project
Feed your pet frog automatically
By Rik SagarThis project was designed to automatically feed my son's pet frogs while we were out of town for two weeks.

How it Works
An Arduino is used to feed the frogs once every two days. The Arduino counts down the necessary number of seconds for two days (configurable in the software). Once this time has passed, an output pin on the Arduino drives a motor, which rotates a hopper to dump food into the frog tank.A sensor, monitoring the food hopper, detects when the hopper has dumped the food and the Arduino turns off the motor. The cycle repeats indefinitely.
Circuit Design

Motor Drive Circuit

Position Sensor

Assembly

Software Design
A short program on the Arduino implements a state machine. The state machine waits for two days, starts the motor, monitors the sensor, stops the motor, then resets the timer to repeat the process two days later. The program will loop forever.As with all Arduino programs, there is a set-up function (setup ( ) ) and a function for the main-loop (loop ( ) ). The set-up function executes once, when the software first starts; the mainloop is called repeatedly while the Arduino is in the normal running state. In addition to those two functions, there are declarations of a number of global variables, macros and some enumerations (custom data types).
Declarations
The first block of code is the declaration of variables and values needed for the application. This is done at the top of the file so the values can be used thoughout the application. This avoids using hardcoded values in the code, for example for things like seconds in a day or the pin numbers of the outputs.• Lines 10-12: Variables identifying the pins used for inputs and outputs
• Lines 17-30: Macros and defines used to control timing. FEED_INTERVAL – defines how long between feedings
MAX_DELIVERY_DURATION – limit the maximum time the motor will remain on
• Lines 35-50: Application variables and state machine definition. next_feeding/feeding_timer – Control when the next
feeding occurs and when it stops. FeedState/feed_state – enumerated type declaring the states of a state machine used
in the main loop to control the application. motorDetect/lastMotorDetect – Read the photo interrupter and detect the end
of a revolution.
Setup
The setup ( ) function sets the modes of the input and output pins, and initializes the outputs. The setup function initializes the application state machine and sets an intial feeding for 10 seconds into the future.Main Loop
The loop ( ) function operates the state machine. The state machine has three states: Waiting for Feeding; Delivering Food; and Finishing Feeding.In Waiting for Feeding, the state machine checks the time against the next feeding time. Once the next feeding time is reached, this state turns on the motor to deliver the food, then transitions to the Delivering Food state.
In Delivering Food, the state machine checks for the photo interrupter to generate a low to high transition, signaling the tab has passed though the interrupter. Once the low-high tranisiton is detected, the state machine transitions to Finishing Feeding.
Additionally, in Delivering Food, the state machine checks whether the motor has been running for more than MAX_DELIVERY_DURATION seconds. If that is the case, the state machine transitions to Finishing Feeding.
In Finishing Feeding, the motor is stopped, the next feeding time is calculated (FEED_INTERVAL seconds after the last feeding time) and the state machine transitions back to Waiting for Feeding.
The state machine is implemented simply as a switch statement with three cases.
Also in the loop ( ) function the LED on the Arduino board is made to flash briefly once per second to show that the application is still running normally.
Enhancements
The performance of the food hopper is, to say the least, disappointing. So, one alteration I am considering is a hopper with a Screw Conveyor. The food hopper is unnecessarily complex and unreliable. A screw conveyor should be a more accurate, less error prone and cheaper solution ($5 rather than the $20 I paid for the fish feeder).Mechanical Design
As the pictures show, the mechanical design of the project is very much a prototype. Once the design is adapted to use the screw conveyor a better housing can be made.For more information visit Rik's website.
If you have an electronics story you'd like to share, please send it to [email protected].