photocell too sensitive?
Most likely you are getting some rapid switching at the threshold level. You need to a little hysteresis to your circuit. Hysteresis is the difference between turn on and turn off and will mean that the signal needs to change significantly before the comparator will change state.



Figure 1. Add resistance between (1) and (2).

Try adding 100k between the points shown in Figure 1. 

How it works:


When light shines on the LDR its resistance will fall. When \$ V_+ \$ input falls below the reference from the pot the output will switch low.
This will pull \$ V_+ \$ even lower so that the light level will have to fall considerably more before the output will switch high again.


Of course, it should also be possible to scrap the circuit and use the 10k and LDR to feed to an analog input on the micro-controller. The hysteresis could then be handled in software.