Skip to content

Instantly share code, notes, and snippets.

@rodrigosetti
Last active August 29, 2015 14:13
Show Gist options
  • Save rodrigosetti/358376263662649ef091 to your computer and use it in GitHub Desktop.
Save rodrigosetti/358376263662649ef091 to your computer and use it in GitHub Desktop.
Automatic Cat Feeder
#define MOTOR_PIN 9
#define FEED_INTERVAL_MS 21600000 // 6 hours
#define MOTOR_TIME_MS 1000 // 1 second (about ~ 1/4 cup)
void setup() {
pinMode(MOTOR_PIN, OUTPUT);
}
void loop() {
feed(MOTOR_TIME_MS);
delay(FEED_INTERVAL_MS);
}
/**
* Feed for n milliseconds
*/
void feed(unsigned long n) {
digitalWrite(motorPin, HIGH);
delay(n);
digitalWrite(motorPin, LOW);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment