I have designed this circuit to switch on a light (R2) when it gets dark. The circuit works fine, however I have a small problem.
simulate this circuit – Schematic created using CircuitLab
As you can probably guess, when it gets dark the voltage at the gate drops and the mosfet is turned off, the relay is turned on and the light is turned on as well. Now as you might have guessed, the light shines on the photoresistor, makes its resistance drop, turns on the mosfet, turns off the relay and turns the light off. This is pretty much an infinite loop...
Of course I could put the photoresistor in a place that cannot be reached by the lamp's light, but I was wondering if one could devise a circuit to avoid such an infinite loop, perhaps a circuit "with memory". What possible solutions could I try?
I thought of a timer that prevents temporarily the mosfet to change state after it has just changed its state, say for the next 12 hours, but I'm not sure how to do such a thing or if simpler options exist.
Then again I might be overthinking things and I could just put the photoresistor in a place not reached by the light of the lamp...