Breathing LED

DickCappels

Joined Aug 21, 2008
10,169
You can see the author's code here. It is merely a loop that ramps up the value to the PWM (my assumption), waits varying amounts of time depending upon the value sent to the PWM, and after running through the loop, repeats. You can change the maximum and minimum apparent brightnesses by changing the value of the first argument in the FOR statement in both places it appears in the code.

ORIGINAL:
for(i = 15 ; i <= 255; i+=1)

MODIFIED SO IT WON'T GET AS DIM:
for(i = 60 ; i <= 255; i+=1)

Keep in mind the fact that to a human eye apparent brightness is a logarithmic function of optical power and is highly affected by the degree of light/dark adaptation of the visual system.

The original Arduino sketch:
http://www.thecustomgeek.com/files/Sleep_LED.pde
 

wayneh

Joined Sep 9, 2010
17,498
I think I'd send a slow cosine wave through the PWM, but "clip" all values that fall below the minimum threshold, holding them at the minimum instead of allowing them to fall. That will give that slight hold time at the minimum value before it throbs again.

Note that "throbbing" is a good search term for this sort of thing.
 
Top