Quote:
Ah, sorry, that is a typo. It was supposed to be (11, 0, 255)! Hope it makes a bit more sense now :-)
Yep I understand now. The fade up for the "sunrise" is 30 minutes. Then a quick fade down of 10 minutes for a "midday rest". Fade up of 10 minutes "midday wake" then a final 30 minute fade down for a "sunset".
Nicely done.
Now one thing you may have noticed that I can't really seem to crack is that the fade looks a bit bright early on.
It turns out that human eyes perceive light in the logarithmic scale, yet our fades are linear. As such things get to full bright at around 25% of the fade cycle and stay that way until 100%
You may have noticed this. That there's not really a "dawn breaking" effect. It's more dawn for a few minutes then fully bright for the rest. That's because our eyes perceive the full brightness at around 25% and from then on it's still full brightness.
Here are the correct values for a true logarithmic fade from 100% to 0% for a 1 byte (255) range:
Code:
255, 180, 128, 90, 64, 45, 32, 23, 16, 12, 8, 6, 4, 3, 2, 1,0
If you implement these values instead of linearly fading from 100% to 0% (via some sort of lookup array) then you will have a nice fade over time.
I tried to do a calculation that would work out the proper PWM value given a minimum and maximum range (so instead of 100% to 0% if I wanted to fade from 80% to 10%) but I couldn't get one worked out (my maths is poor).
See what you think of the logarithmic fade instead of linear. It's a more gradual effect and I'm sure it's not an issue for the plants. It just means the dimmer values are held a bit longer and so the lights don't look full bright too quickly.