Chicken Coop Door Code
- January 12th, 2010
- Posted in Uncategorized
- Write comment
I’ve been writing the code for my arduino controlled chicken coop door. This is what I have so far:
// Troy Watson Arduino Powered Chicken Coop Door
// Waits for the sun to come up, turns a servo to open a drawbridge then waits and closes the bridge.
#include <Servo.h>
Servo servo0; // create servo object
int sensVal = 0; // analog pin used for light sensor
int rotateDeg = 1080; // number of degrees to lower drawbrigde
int darkVal = 55;
void servoUp()
{
servo0.write(rotateDeg); //tells the servo to turn out the winch
}
void servoDown()
{
servo0.write(-1*rotateDeg); //writes the servo to turn back up?
}
void setup()
{
servo0.attach(9); // attaches the servo on pin 9 to the servo object
}
void loop()
{
if (sensVal > darkVal){ // duh
delay(360000); // waits 6 minutes
if (sensVal > darkVal){ // checks the sensor again to make sure its really the sun not just some retard in the neighbors driveway
servoDown(); // lets door fall open gracefully
delay(43200000); // waits 12 hours.
servoUp(); // pulls door back up
}
}
}Download it here.
No comments yet.