I have searched around this site as well as google for some programming to automate my coop door. Unfortunately none of them seem to have the same plans as I do.
I am hoping somebody can direct me to some instructions on how to make the following work:
-A DC linear actuator to lift up at sunset, then close at sunset.
-Photoresistor to measure ambient light and trigger actuator
I can find instructions for each of those items, but nothing that combines the two.
Yes, I have a 2 relay switch module for the dc motor.
Throwing a hail mary here, hoping somebody might be able to help out.
First, do you have any code you want to use, if so, please post it! Secondly, i wouldn't use a photo resistor do it inconsistencies such as clouds, shadows, birds:), etc...
Personally, i would use delay if that is all you need to do and you don't need to be able to move to actuator manually. I know someone will suggest using millis, but i would not use it for something that will need to run for more than 49 days because it will make the code more complex due to the fact that millis() will become to large and will need to be reset. Also, it would not be necessary for a code like this.
Thanks for the reply
No I don't have any specific code, apart from the basic CW, CCW (clockwise, counter clockwise) stuff for the actuator.
A delay would not be ideal, as it would continually need to be modified during weeks that pass by (changing daylight hours). I would prefer for it to adjust automatically with daylight hours.
As the chickens are always in by dark, I figured if I could add a delay after the photocell threshold was met, that way I could ensure no late straggler chickens were locked out. That was my preference for the photosensor.
DH12043:
but i would not use it for something that will need to run for more than 49 days because it will make the code more complex due to the fact that millis() will become to large and will need to be reset.
Bullsh*t. Do a little research. Learn about subtraction of 'unsigned long' variables. As long as you don't need to time a single event for more than 49 days, millis() is just fine. Sounds like here the largest possible event length will be 24 hours.
I've used an LDR in series with a 47K resistor to do what you are describing and it worked well, but without specifics on your actuator, relays, Arduino and other components, thats about all I can say.
I have a two channel relay module I have successfully been using to extend and retract my 16" 12volt linear actuator. This schematic makes sense to me, is there a program to go with it?
Thanks again to everyone for your expertise!
I love the manual up/down for this larryd. I am embarrassed to ask for some direction on the programming of the bottom sketch. Like I said, I am a noob.
My programming skills are still in the early stages.
There are some example sketches that come with the Arduino IDE.
If you study these, you will see how to read an analog input and control an digital output.
Since the LDR is connected to the Analog input A0, you can read the LDR voltage divider with.
myLightSensor = analogRead(A0);
For the testing phase you can print the reading to the serial monitor.
Later you can remove the print function, when the project is installed in its final location.
Serial.println(myLightSensor);
You can use this reading to determine if it is time to open the door.
if(myLightSensor > openLevel) {digitalWrite(doorPin,HIGH);}
Later you can close the door with:
if(myLightSensor < closeLevel) {digitalWriter(doorPin,LOW);}
You can added a time delay if needed to achieve door response.
You can add hysteresis to the 'if()' to prevent weird things happening at the switch over event.
Note the sensitivity of your LDR will determine what the value of R8 should be.
Also you can swap R8 an the LDR to reverse the voltage change action on A0 if you need.
An RTC can be used in conjunction with the above.
You will have to experiment with values to handle cloud cover.