The objective of this bit of the program is: A dusk to dawn timer using an LDR which turns the lights on at dusk and OFF at midnight or so, not waiting for dawn. At dusk on the first loop it starts a counter (Count). At dawn, Count is divided by 2 in (HalfTime), then zeroed. On the second and subsequent dusk to dawn period I want to turn the lights off when Count = HalfTime. As Count gets shorter through Summer so does HalfTime. This will reduce the required battery recharge time. I still want Count to carry on counting even though HalfTime has turned the lights off.
My problem is that I can’t retain HalfTime in the dusk/dawn period. Wherever I zero Count it zeroes HalfTime. It’s driving me mad. I’m missing something basic.
Any advice or pointers much appreciated. My first post. Please point out bad practice if any
int LED = 9;
int LDR = A0;
if (LDRValue <1000)// ie is dark - turn lights on
Serial.print("Count lights are on = ");
//if Count = HalfTime LED,LOW etc
Serial.print("HalfTime light on = ");
Serial.print("HalfTime light off = ");
Count = 0;
Serial.print("Count lights off = ");