Help with Dave Naves Chicken Coop

I was wondering if someone could help me with adding an override button to open and close this chicken coop door using this code which is from Dave’s project?

I am also trying to make it work off of using a Real Time Clock to set time points to control instead of using the photocell.

I appreciate all of your help and cant wait to figure this out.

Dave Naves Chicken Coop Video (Click Here)

Dave_Naves_Chicken_Coop_Controller.ino (18.2 KB)

Uniquemind:
I was wondering if someone could help me with adding an override button to open and close this chicken coop door using this code which is from Dave's project?

I am also trying to make it work off of using a Real Time Clock to set time points to control instead of using the photocell.

It 's not clear to me if you are trying to figure out the changes yourself or if you just want someone else to do them for you. If the latter then you should ask in the Gigs and Collaborations section and be prepared to pay.

If you are just looking for help with your own coding then please post the code that represents your best attempt and tell us in detail what it actually does and what you want it to do that is different.

As you are starting with a long program it would also be a big help if you point out where you have made the changes or additions.

...R

Hi, can you post the code as described in the forum guide please? Most of us read the forum on phones/tablets and can't open a .ino file.

Code is too big to post inline :wink:

Sorry about that the code is to big to post in the forum.

I have been working on modifying the code and have most of it working

I am trying to add my override open and close, but it’s not working.

I will attach the modified version I am working on

I am only going to use a UNO board with this project so I’m not using all the functions that are in this code. I didn’t remove them because I may add them in at a later date.

I am not using a LCD for now either

I have two files attached one is to set the time on the RTC and the other is the main code

I am only going to have the chicken coop do the following for now

Open door at set time
Close door at set time
Override open
Override close
LED status of open and close

I am not an expert at this I am fairly new so I apologize if something that I explain or do isn’t to proper detail.

thank you for all of your help with this.

10-12-2019_Chicken_Coop.ino (20.5 KB)

Set_Time.ino (1.71 KB)

I think that this part would help

if you have an extra pin, think along these lines

if (extra_pin == HIGH) {
openCoopDoorMotorB()
}

the problem you face is interrupting the existing program and then letting it resume automatic.

with a button that would put the unit into manual and have the door go to the opposite state that it is currently in, would make sense.
also, once the light changes to the next thing, it could automatically put the sketch back into automatic.

// close the coop door motor (motor dir close = clockwise)  
void closeCoopDoorMotorB() {   
  digitalWrite (directionCloseCoopDoorMotorB, LOW);     // turn on motor close direction 
  digitalWrite (directionOpenCoopDoorMotorB, HIGH);       // turn off motor open direction 
  digitalWrite (enableCoopDoorMotorB, LOW);               // enable motor, full speed  
  if (bottomSwitchPinVal == 0) {                         // if bottom reed switch circuit is closed 
    stopCoopDoorMotorB(); 
    Serial.println(" Coop Door Closed - no danger"); 
     
     } 
} 
 
 
 
// open the coop door (motor dir open = counter-clockwise) 
void openCoopDoorMotorB() {  
  digitalWrite(directionCloseCoopDoorMotorB, HIGH);       // turn off motor close direction 
  digitalWrite(directionOpenCoopDoorMotorB, LOW);       // turn on motor open direction 
  digitalWrite(enableCoopDoorMotorB, LOW);                // enable motor, full speed 
  if (topSwitchPinVal == 0) {                            // if top reed switch circuit is closed 
    stopCoopDoorMotorB(); 
    Serial.println(" Coop Door open - WARNING!"); 
     
  } 
}

Sorry about that the code is to big to post in the forum.

Yeah, I skimmed through it. Is a good effort for a beginner, but shows some lack of skill & understanding. That's largely why it's so long. For example there is half a page of code to debounce the reed switch at the top of the door. Then, that same code had been copied to make another half page of code for the bottom reed switch. Its the same code with a different pin number, which could easily have been avoided. The ironic thing is, you don't need to debounce those reed switches at all! Not because they are reed switches, because they are limit sensors. If the bottom sensor is triggered, the door is at the bottom and the code stops the motor. If it triggers a second time due to bouncing, the door is still at the bottom, the code does not need to do anything more/different, so debouncing is pointless. The author probably read advice somewhere written by another beginner that said "its a switch, you must debounce it". But debouncing is only needed for certain purposes like keyboards/pads, mode selection switches etc.

Anyway, enough ranting from me. I just wonder if using that code as the basis for your project makes life easier or harder!

Dave Naves uses a cover and flashlight to override the operation.
puts a shield over the sensor, the sketch reacts as if it were night and closes the door.

if you wanted to put in a override, sending a momentary signal to open or close the door is not that hard, but since light overrides, the sketch would need to have a time-out. If you want to do maintenance, say sweep the coop, you could make that time out for 30 minutes, then the automatic would take control yet again.
or, you could open the door, and turn off power to it.