Automated Fish Feeder Project

By Agustin December 28, 2012

Here is a project I whipped up because I needed it, STAT! Derpy II, Pish and Zeet’s lives depend on it. Thanks to Instructables, Tinkercad and the Printrbot, I was able to get this all designed assembled and programmed in a few hours.

Big props to this instructable for the base idea. I modified the code quite a bit, and only used one servo in my design.

I’ll post to tell you if it works out… eeek! Update: SUCCESS


//**************************************************************//
// Name : Fish feeder V3
// Author : Agustin M. Sevilla
// Date : 12/29/2012
// Modified: 12/30/2012
// Version : 3.0
// Notes : Derived from an instructable I found, this sketch uses a servo to actuate a fish feeding mechanism. I feed my fish little pellets.
// The algorithm was modified a lot to allow for an implementation using one servo, and incrementally wiggling harder to get out
// more pellets as the container empties over time.
// References: Parent object http://www.instructables.com/id/Automatic-Fish-Feeder-in-20-minutes/?ALLSTEPS
// 3D parts https://tinkercad.com/things/7HaZFJbqqAQ //
// Uses part of the servo sweep arduino example in function smoothWiggle()
//****************************************************************

#include

//Feed schedule
unsigned long initial_delay = 43200000;// Start 12 hours from now
unsigned long feed_time = 10800000;// Feed every 3 hours

int feed_count = 0;
int num_shakes = 1;
//Servo
Servo feederServo;
//Status LED
int ledPin = 10;

void setup() {
Serial.begin(9600);

//Set up our servo
feederServo.attach(9);
feederServo.write(90);

pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, HIGH);

delay(500);
feederServo.detach(); // Detach and remove power

delay(initial_delay);

}

void loop(){

digitalWrite(ledPin, LOW);

feederServo.attach(9); // Re-attach and apply power

int i =0;
int j =0;
int jerk_pos = 0;

//FEED FISHY
for (j =0; j < num_shakes;j++) { if (j < 6) { jerk_pos = 130 - (j *10); } else { jerk_pos = 80; } //Cock servo back feederServo.write(130 - (j *10)); delay(300); //Put in dump position & hold feederServo.write(0); delay(500); //Wiggle out pellets for (i =0; i < 2;i++) { smoothWiggle(50); } } feederServo.write(90); delay(250); if (num_shakes < 5) { num_shakes++; } feed_count++; //Detach Servo to avoid wasting power feederServo.detach(); // Detach and remove power digitalWrite(ledPin, HIGH); //Repeat every... delay(feed_time); } void smoothWiggle(int limit) { int pos; for(pos = 0; pos < limit; pos += 1) // goes from 0 degrees to 180 degrees { // in steps of 1 degree feederServo.write(pos); // tell servo to go to position in variable 'pos' delay(5); // waits 15ms for the servo to reach the position } for(pos = limit; pos>=1; pos-=1) // goes from 180 degrees to 0 degrees
{
feederServo.write(pos); // tell servo to go to position in variable 'pos'
delay(5); // waits 15ms for the servo to reach the position
}
}

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *