Re: Code question

Because straight after triggering, you don't have a delay, so "loop" gets called again, and the light level is still sufficient to trigger the shutter again. Possibly.

Removing the abs() call should take care of the problem. With it in, the delta from light to dark and dark to light are always positive and greater than TRIGGER_THRESHHOLD, so each transition causes a trigger.

if (abs(newLightningVal - lightningVal) > TRIGGER_THRESHHOLD)

will become

if ((newLightningVal - lightningVal) > TRIGGER_THRESHHOLD)

I'm making a assumption that the analog value for light is greater than the value for dark. If it's the opposite, just swap the values in the equation to this:

if ((lightningVal - newLightningVal) > TRIGGER_THRESHHOLD)