Report as inappropriate

it would be very easy to use this code as it is with a toggle switch or a push-on-push-off button. simply connect one side of the button to 5v, and the other side to analog pin 0 with a 10K resistor to ground, on the arduino side of the switch so that the pin will not have a floating voltage state. the digital function of the switch or button will be just like the light level of the photo resistor going from 0 to 1024.

if you wanted to use a momentary push button to activate this code, the codce would not work without changes.