cat feeder, servo motor

Hi all,

I'm fairly new to programming. Yet I figured out how to program the servo motor to get the right food dosis per loop in my cat feeder. There are two things that I want to add to the programing and I would like to get opinions on the best way to do this.

1- I want the feeder to be activated by the cat, I'm thinking about using a cat toy and turn it to a switch that would be connected to the gnd of the servo.4

2- I want to limitate the amount of loop the servo would do in a day so my cat doesn't reach a Garfield shape!

thanks for helping!

You can count the number of feeds and not let it go over a certain value.

At midnight you could reset the counter for the next day, use an RTC.

A simple light beam interruption technique could be used for triggering, maybe a toy could swing to interrupt the light.

Maybe allow 2 small feedings every hour to a maximum per day.

Here’s the code I’m using to set the right loop for cat feeder.

#include <Servo.h>

Servo myservo;  // create servo object to control a servo
// twelve servo objects can be created on most boards

int pos = 0;    // variable to store the servo position

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

void loop() {
  for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees
    // in steps of 1 degree
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(15);                       // waits 15ms for the servo to reach the position
  for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(15);                       // waits 15ms for the servo to reach the position

what I’m looking for is:

1- A way to code a trigger to the beginning of the loop with a motion sensor
2- The loop should’nt repeat without being triggered again.
3- The loop should’nt repeat within an hour after being triggered once.

I might not be using the right wording when searching on the web as I thought this would be quite simple to find out. Again I’m a total noob when it comes to programming…

First things first, you need to finalize the hardware connections for this project.

Draw a schematic of your circuit and show it to us.

For example your components might include: RTC (DS3231), Servo model xxx, photo resistor, IR sensor, distance sensor, manual feed switch (human operated), power supplies, Arduino type, etc.

Once you have your hardware and schematic decided on, you can then start writing your code.

Don’t blindly copy other people’s code and expect things to be applicable to your situation.

Is this project for a school assignment?