Pedro Mendez
Published

Lane Tech HS - PCL - <Automated Dog Food Dispenser>

An automated dog food dispenser that can be controlled via a timer, knob, or a button on your phone.

IntermediateShowcase (no instructions)3 hours613
Lane Tech HS - PCL - <Automated Dog Food Dispenser>

Things used in this project

Hardware components

Plastic Container
×1
Can
×1
Rotary potentiometer (generic)
Rotary potentiometer (generic)
×1
Breadboard (generic)
Breadboard (generic)
×1
Photon
Particle Photon
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Servos (Tower Pro MG996R)
×1

Software apps and online services

Maker service
IFTTT Maker service

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Hot glue gun (generic)
Hot glue gun (generic)

Story

Read more

Schematics

Food Dispenser Circuit

Code

Food Dispenser Code

C/C++
Servo myservo;  // create servo object to control a servo

int potpin = A1;  // analog pin used to connect the potentiometer
int val = 0;    // variable to read the value from the analog pin

int myMinute = 52;  //53
int myHour = 22; //10 pm
int servoPin = D0;
void setup() {
 
  myservo.attach(servoPin);  // attaches the servo on pin 9 to the servo object
  myservo.write(0);
  
  Time.zone(-6);
  Particle.syncTime(); //sync with the Particle Cloud's time
  Particle.function("feed", triggerFeed);
}

void loop() {
    
  val = analogRead(potpin);            // reads the value of the potentiometer (value between 0 and 4095)
  val = map(val, 0, 4095, 0, 179);     // scale it to use it with the servo (value between 0 and 180)
  myservo.write(val);                  // sets the servo position according to the scaled value
  delay(15);
  
  if(Time.hour() == myHour && Time.minute() == myMinute) //check the time
      {
        myservo.attach(servoPin);
        myservo.write(135);//set to a position to dump the food
        delay(5000);
        myservo.write(0);//set to a zero position
        delay(500);
        //myservo.detach();//detach to keep the servo from jittering

        delay(60000);//wait the rest of the minute out
      }                           // waits for the servo to get there
    
}

int triggerFeed(String command)
{

    if (command=="feed")
    {
        myservo.attach(servoPin);
        myservo.write(135);//set to a position to dump the food
        delay(5000);
        myservo.write(0);//holding position
        delay(500);
        //myservo.detach();
        return 1;
    }
    else
        return -1;
}

Credits

Pedro Mendez

Pedro Mendez

2 projects • 2 followers

Comments

Add projectSign up / Login