void loop()
{
int in = analogRead(A0);
//coming to if statements
if (in <= 30)
{
digitalWrite(10, HIGH);
}
else
{
digitalWrite(10, HIGH);
delay(5000);
digitalWrite(10, LOW);
}
if (in >= 30)
{
digitalWrite(11, HIGH);
}
else
{
digitalWrite(11, HIGH);
delay(5000);
digitalWrite(11, LOW);
I am using it for automatic roller curtain when it will be be under the exposure of sun it should close the curtain and the curtain takes 10 sec to close or open the curtain.
Relying on a timer to open and close curtains is a bit hit and miss.
You should have limit switches to indicate fully open and fully closed.
If you leave or someone moves the curtains to half open, then a fixed time in either direction will try to over drive your curtains and stress your motors and controller.
You would also need some form of manual control to operate the curtains when it is dark or sunny.
Have you tried to see if the motor/gearbox and motor controller can do the job?
When LDR is exposed to sun its value is less tan 30. It should be able to rotate the motor for 5 sec irrespective, for how much time it is exposed to sun.