Light and time dependent switch

Hi,

is ur switcher actually a button or really that sensor?

Can you rephrase ur last text? I dont really understand it.

If u use no delay in the code the led is flickering?
If u use delay of 100 there is no led flickering?
And if u use a very small delay of like 1 the led is flickering too?

As I said, using delay() in code is like blocking the arduino from doing anything else. That could also mean the led is still turned on because of the delay when in fact it would be off. Might relate to that flickering or other weird behaviour, not sure.

Try to work with millis instead of delay, just type into google "millis instead of delay" and u will find plenty of info.

I dont know about your circuit but maybe u need something like a pullup or pulldown resistor for the sensor