Autonomous chicken coop

I love fresh yard eggs, but I'm lazy.
to solve the first problem I'm converting an old 6X6 shed into a coop for 4-5 chickens.
to solve the second problem I'm going to automate all the tedious things, like calling them in at night and feeding.
my goal is to go out about once a week to collect eggs, add feed and clean poo.
I know very little about code, but a bit about electronics.
I'm looking for someone to proof my code and tell me if I'm heading in the correct direction.
keep in mind this is not finished.
I originally plan on using a DS18B20 to sense temp and turn on a fan or heater accordingly. but due to the complex nature of this device I decided to go with a very simple thermal resistor connected to the analog in.

on a final note, all # are just to start, I will re-calibrate as as soon as I get everything hardwired and settled

/*
 
 The circuit: 
 * 20k Ohm resistor from +5V to pin 1, and a photo resistor from analog pin 1 to Gnd 
 * 140k Ohm resistor from +12V to pin 2, and temperature resistor from analog pin 2 to Gnd 
 * a 5VDC buzzer connected from "high" to pin 5, and 5VDC on pin + and gnd on pin - 
 * a 5VDC actuator connected through a relay from pin 6 to gnd
 * a 120 VAC 12" fan connected thorugh a 5VDC relay from pin 7 to gnd
 * a 120 VAC 100W heat lamp connected thorugh a relay from pin 8 to gnd
 * a 120 VAC light bulb connected through a relay from pin 9 to gnd
 * a normally open push button connected from +5VDC to pin 10
 * a normally open push button connected from +5VDC to pin 11
 * a 5VDC actuator connected through a relay (cw in ON state and ccw in off state with limit swithces in place to ensure secure open/close) from pin 6 to gnd

 
 * note to self 1-5 are analog, move accordingly
 * also PWM pins are 3, 5, 6, 9, 10, and 11
 
 
 created Feb 2010
 by Jake Dixon 
 jakedixon@hotmail.com
 
 
*/

// set pin numbers:
int PhotoPin = 1;        // photo pin
int TempPin = 2;         //temp sensor
int BuzzPin = 5;         //OMG food!
int FeedPin = 6;         //dispenses feed
int FanPin = 7;          // exhaust fan
int HeatPin = 8;         // heat lamp
int LightPin = 9;        //night light
int Closepin = 10;       // Door close button
int Openpin = 11;        // Door open button
int DoorPin =  12;       // Door actuator relay


// variables will change:
        
int OpenState = 0;               // variable for reading the pushbutton status
int CloseState = 0;              // variable for reading the pushbutton status
int Bright = 0;                  // variable for photo pin
int temp = 0;                   // variable for temp cold
int flip = HIGH;                // variable for me to get confused with flop
int flop= LOW;                  // variable for me to get confused with flip

void setup() {
  pinMode(BuzzPin, OUTPUT);
  pinMode(FeedPin, OUTPUT);
  pinMode(FanPin, OUTPUT);
  pinMode(HeatPin, OUTPUT);
  pinMode(LightPin, OUTPUT);
  pinMode(DoorPin, OUTPUT);   

}

void loop()
{
  // ******** Define int ********
  OpenState = digitalRead(Openpin);
  CloseState = digitalRead(Closepin);
  Bright = analogRead(PhotoPin) / 4;
  temp = analogRead(TempPin);


  // ****** manual operation  ******

  if (OpenState == HIGH)                //  if open button is pushed 
  {
    digitalWrite(DoorPin, HIGH);    // open the door
  }
  if (CloseState == HIGH)            // if close button is pushed
  {
    digitalWrite(DoorPin, LOW);      // close the door
  }
  // ********Morinig Routine********
  if ((flip == HIGH) and (Bright > 100))     //if it's light out and morning is enabled
  {
    digitalWrite(DoorPin, HIGH);      // open the door
    digitalWrite(flip, LOW);         // enable night mode
  }
  // ********Evening Routine********
  if ((flip == LOW) and (Bright < 80))    // if it's dark out and night is enabled
  {
    digitalWrite(LightPin, HIGH);       // turn on the light
    delay (5000);                        // wait 5 seconds
    digitalWrite(BuzzPin, HIGH);        // turn on the dinner bell
    delay (5000);                        // wait 5 seconds
    digitalWrite(FeedPin, HIGH);        // food dispenser on
    delay (800);                        // let it run for .8 seconds, no fat chickens here
    digitalWrite(FeedPin, LOW);        // food dispenser off
    delay (14200);                       // delay 14.2 seconds more
    digitalWrite(BuzzPin, LOW);         // total dinner bell time 20 seconds
    delay (300000);                     // wait 5 min for all the chickens to get home
    digitalWrite (DoorPin, LOW);        //close the door
    delay (300000);                    // lets everyone get settled
    digitalWrite(LightPin, LOW);       // sleep tight
    digitalWrite(flip, HIGH);
  }
//temp reg 
  if ((temp < 80) and (flop== LOW);
 { digitalWrite(FanPin, HIGH);
 digitalWrite (flop, HIGH)
 }
 if (temp < 90);
{ digitalWrite (FanPin, HIGH) ;
digitalWrite (flop, LOW)
}
}
digitalWrite (flop, HIGH)

This and one other statement are missing ; at the end. More than that, though, can you explain what this is supposed to do? This is not how to change the value of flip or flop.

      digitalWrite(BuzzPin, HIGH);        // turn on the dinner bell

Can you shut that damned buzzer off? A person can think with all that racket going on!

Seriously, though, does the thing really need to make a racket for twenty seconds?

Some things to consider. What happens if it's very cloudy, and your light sensor reading drops below 80? The dinner bell rings, food is dispensed, and the chickens have 5 minutes to get in before the door is locked.

The cloud passes, and the sensor reading goes back above 80, and the door is opened. Another cloud, and the chickens get fed again. Comments notwithstanding, your going to go through a lot of food this way, and have fat chickens.

good point on the cloud thing, I plan on solving this by recalibrating all my set values during real situations. right now I just needed something to fill the holes.
O yeah? every 20 seconds? I should have clearly stated what I wanted.
in the evening when the sun goes down I want the photosensor to trigger the following

f ((flip == LOW) and (Bright < 80))
 // ********Evening Routine********
 if ((flip == LOW) and (Bright < 80))    // if it's dark out and night is enabled
 {
   digitalWrite(LightPin, HIGH);       // turn on the light
   delay (5000);                        // wait 5 seconds
   digitalWrite(BuzzPin, HIGH);        // turn on the dinner bell
   delay (5000);                        // wait 5 seconds
   digitalWrite(FeedPin, HIGH);        // food dispenser on
   delay (800);                        // let it run for .8 seconds, no fat chickens here
   digitalWrite(FeedPin, LOW);        // food dispenser off
   delay (14200);                       // delay 14.2 seconds more
   digitalWrite(BuzzPin, LOW);         // total dinner bell time 20 seconds
   delay (300000);                     // wait 5 min for all the chickens to get home
   digitalWrite (DoorPin, LOW);        //close the door
   delay (300000);                    // lets everyone get settled
   digitalWrite(LightPin, LOW);       // sleep tight
   digitalWrite(flip, HIGH);

open door (just in case I close the door during the day and forget about it)
turn on a light
wait 5s
turn on a audio alarm
wait 5 seconds
...
turn off the light.
then next thing i want it to do is wait till morning. not keep turing on the light and opening/closing the door.
that's why I did the set flip to HIGH.
what would be the correct way to disable the "evening routine" and enable "morning"
and vice versa
thanks for your time

flip and flop are variables. To change flip from HIGH to LOW:

flip = LOW;

In the long run, you will need to get rid of all the delay statements you are using now. Look at the Blink Without Delay example for how to do this.

You will also want to create functions, like feedTheChickens(), openTheDoor(), closeTheDoor(), etc. that perform various actions. Loop will then just need to call the appropriate function at the appropriate time.

Basically, what you are trying to do is implement a state machine (night is a state, so is day). There should be sensors whose status is read to determine when to transition from one state to another (it's dark, so transition to night).

Things happen at transitions (feed the chickens when night occurs) and during states (it's daytime; do nothing).

Read up on state machines in the playground. It will make your job much easier.

Will do.
thank you.
so this work? or is it too N00b like?

It can be made to work. You are going in the right direction.