PWM led fading over a specified time period


I have a string of leds which I want to be able to fade in/out over a 30 min period. PWM seems to be the obvious answer. But looking through various posts and articles etc, I can’t find any reference to intergrating PWM over a specified time period. Has anyone tried this, can you give me a steer in the right direction.

Also I’m planning on a logic level MOSFET to control the 12v supply. Has anyone played with these?


Simple if you want to output something that goes from 0 to 255 in 30 mins you need to change it every 30/255 = 0.1176 mins or 7.05 seconds.

So use millis() + 7050 to get the time for the next change. Then keep looking at the current value of millis() until it exceeds this figure. Increment the value (or decrement) sent to the PWM and set the time again.

Hi Grumpy_Mike

Many thanks for your reply. I had no idea it would be so simple. As usual you ARE the Guru.

All the Best