Dustin MesserElijah Wells
Published

Motion Activated Dog Feeder

Our project makes life easier by letting the dog feed itself when needed.

IntermediateShowcase (no instructions)8 hours1,179
Motion Activated Dog Feeder

Things used in this project

Hardware components

Photon
Particle Photon
×2
Servos (Tower Pro MG996R)
×1
PIR Motion Sensor (generic)
PIR Motion Sensor (generic)
×1
Solderless Breadboard Half Size
Solderless Breadboard Half Size
×2
Bowl
×1
Dog food
×1
funnel
×1

Software apps and online services

Maker service
IFTTT Maker service
Particle Build Web IDE
Particle Build Web IDE
Google Sheets
Google Sheets

Story

Read more

Schematics

servo schematic

This schematic shows how the servo is hooked to the photon

PIR sensor schematic

This schematic shows how the PIR sensor is connected to the Photon

Code

Sevo Code

C/C++
This code programmed the servo to rotate when needed
// subscribes the receiver Photon to the published events from the
// mesauring Photon. In the last arguement for the subscribe function, enter
// the device ID from the publishing Photon.
Servo myservo;  // create servo object to control a servo
                // a maximum of eight servo objects can be created

int pos = 0;    // variable to store the servo position
void setup() {
    


    myservo.attach(D0);   // attach the servo on the D0 pin to the servo object
    
    pinMode(D7, OUTPUT);  // set D7 as an output so we can flash the onboard LED


   
    Particle.subscribe("MotionIn", b,"2c002400184734348323536");
   
}
// converts Unix time data from subscribe functions to an integer value


void b(const char *event, const char *data) {
     
        {
            myservo.write(0);       // move servo to 25
            digitalWrite(D7, HIGH); // flash the LED
            delay(2000);             // wait 100 ms
            myservo.write(90);      // move servo to 180°
            digitalWrite(D7, LOW);  // turn off LED
            delay(1000);            // wait 1 second 
        }
        
    }

PIR Sensor Code

C/C++
bool alertedin;

void alertin();


// PIR motion detection is running off interrupt functions, which once triggered
// will run either "alertout" or "alertin" functions. Pins D1 and D2 were
// selected as signal inputs from the PIR sensors.
void setup() {
    pinMode(D1, INPUT);

    attachInterrupt(D1, alertin, RISING);

    alertedin = false;

}

// publishes an event to Particle Console when either the outside or
// inside PIR sensor is triggered
void loop() {
 
    if (alertedin == true) {
          Particle.publish("MotionIn",String(Time.now()),21600,PUBLIC);
            alertedin = false;
    }
}

// sets booleans to true to tigger publish event in running loop


void alertin() {
    alertedin = true;
}

Credits

Dustin Messer

Dustin Messer

1 project • 1 follower
UNCC mechanical engineering major
Elijah Wells

Elijah Wells

1 project • 1 follower
UNC Charlotte Mechanical Engineering Major

Comments