Go Down

Topic: Re: Code question (Read 654 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.


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

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131