Go Down

Topic: Re: Code question (Read 686 times) previous topic - next topic


Jul 02, 2009, 08:18 pm Last Edit: Jul 02, 2009, 08:18 pm by AWOL Reason: 1
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.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.
I speak for myself, not Arduino.


Jul 02, 2009, 08:38 pm Last Edit: Jul 02, 2009, 08:48 pm by mrbill Reason: 1
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.

Code: [Select]
if (abs(newLightningVal - lightningVal) > TRIGGER_THRESHHOLD)

will become

Code: [Select]
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:

Code: [Select]
if ((lightningVal - newLightningVal) > TRIGGER_THRESHHOLD)

Go Up