Wednesday, April 4, 2018

Build a Vacation Pet Feeder!

Code:


/* Pet Feeder by William Finucane

 This code is for use with an automatic pet feeder made for the
Mad Science World at http://mad-science.wonderhowto.com/
The feeder uses a gluestick attached to a continuous rotation servo
as a linear actuator. This actuator opens and closes a compartment
of food every 12 hours to feed any domoestic animal

This example code is in the public domain.
*/
#include  

Servo myservo;  // create servo object to control a servo
                // a maximum of eight servo objects can be created


void setup()
{
  myservo.attach(10);  // attaches the servo on pin 9 to the servo object
}


void loop()
{
                                 
    myservo.write(80);             //open food gate
  delay(10500);                    //at this speed it takes 10.5
                                   //seconds to
                                   //open all the way
  myservo.write(120);              //close food gate
  delay(10000);                    // at this speed it takes 10 seconds
  myservo.write(96);               //hold gate still
  delay(43200000);                  //wait 12 hours
 
  /* the opening of the gate is longer than the closing to make
  sure the glue stick slide never comes out of the case. If the
  feeder is jostled, the extra half a second added upon closeing the
  gate will retighten the slide.
  */
}

No comments:

Post a Comment