Skip to content

Instantly share code, notes, and snippets.

@mbrav
Created August 10, 2016 07:53
Show Gist options
  • Save mbrav/6056e5952cf3a98ffe74918139780017 to your computer and use it in GitHub Desktop.
Save mbrav/6056e5952cf3a98ffe74918139780017 to your computer and use it in GitHub Desktop.
Self feeding mechanism for feeding fish.
// Feeduino - Automatic Fish Feeder
// (c) Michael Braverman, November 2012.
// Video: https://youtu.be/1IwfZIiVXiA
#include <Servo.h>
Servo sServo; // Sweep servo (the one on the top)
Servo rServo; // Rotate servo (the one on the bottom)
int sDef = 70; // Sweep servo default possition
int rDef = 180; // Rotate servo default possition
int sFeed = 180; // Sweep servo possition when feeding
int rFeed = 55; // Rotate servo possition when loading with food
void setup()
{
sServo.attach(A1);
rServo.attach(A0);
}
void feed ()
{
sServo.write(sDef);
rServo.write(rDef);
delay(1000);
sServo.write(sDef);
rServo.write(rFeed);
for (int i = 0; i < 10; i += 1) { // Shaking techinique in order to fill the cap more efficently.
rServo.write(rFeed);
delay (50);
rServo.write(rFeed + 20);
delay (50);
}
delay(300);
for(int i = rFeed; i < rDef; i += 1)
{
rServo.write(i);
delay(25);
}
delay (1000);
sServo.write(sFeed);
for (int i = 0; i < 35; i += 1)
{
sServo.write(sFeed);
delay (40);
sServo.write(sFeed - 4);
delay (40);
}
sServo.write(sDef);
rServo.write(rDef);
delay(170);
}
void loop()
{
feed ();
sServo.detach();
rServo.detach();
delay (6000);
sServo.attach(A1);
rServo.attach(A0);
// delay (43200000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment