LED dimming

Hi everyone!

I was trying to get some result from the example below where the LED’s intensity would follow the timer(the value of it)

int led = 9;

int timer = 0;

void setup()
  pinMode(led, OUTPUT);

void loop()
for (timer = 0; timer < 255; timer++)
  analogWrite(led, timer);

Can anyone point me where my mistake is?

Thank you for the responses in advance. Best regards.

Can anyone point me where my mistake is?

I guess you not telling what’s wrong ?

As i’m guessing already, your eyes might be too slow to see the brightness ramping up.
Put another delay within the curly brackets in your “for…” loop.

How could I've not thought of that.

I knew that it was going too fast, I just didn't try adding a delay in the for loop. That wraps it up.

Thank you for your help.

Next: Let the LED go off smoothly too, and have it go on and off in different speeds. I'm sure you can think of some more small variations to play with the hardware as it is right now, i's a lot of fun to see happening what you had in mind. :grin:

Then do it without using delay()