Pages: [1]   Go Down
Author Topic: Re: Code question  (Read 354 times)
0 Members and 1 Guest are viewing this topic.
Global Moderator
Offline Offline
Brattain Member
Karma: 310
Posts: 26634
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: July 02, 2009, 01:18:50 pm by AWOL » Logged

"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.

SF Bay Area
Offline Offline
Karma: 0
Posts: 13
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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)
« Last Edit: July 02, 2009, 01:48:59 pm by mrbill » Logged

Pages: [1]   Go Up
Jump to: