slow lighting or dimming

Hello there, have started with a very simple for loop to brighten/or dim an led lamp.

// Dim an LED using PWM
int PWMpin = 10;

void setup() {


void loop() {
for (int i = 0; i <= 255; i=i++)
analogWrite(PWMpin, i);

Can anyone suggest the approach I could take to make a very slow dim/brighten loop up to 60 minutes or longer, or is a ‘slow loop’ not a good approach to this, would appreciate some suggestions as to how I might approach this, thanks.

Just change the delay to make the process longer.

To make that code last an hour then the delay should be for:- (60 * 60) / 256 seconds

artuksa: is a 'slow loop' not a good approach to this

It depends what else you need your Arduino to do at the same time. If it needs to react to events like button presses during lighting/dimming, then this slow loop is not suitable. But if the Arduino has nothing else to do, then its OK.

Thanks for the replies, appreciated