Interesting if you dig down into the source code for the analogWrite() function, I believe that analogWrite(pin,0); results in simply using a digitalWrite(pin, LOW). As I recall in some early IDE versions the analogWrite(pin,0) showed up a bug where instead of a constant low output there was a single one count duty cycle output and would show up as as very dim light if wired to a high efficiency led. I recall hooking up my oscilloscope to a PWM output set to 0 and still seeing a single high pulse, so something was screwy with the timer counter/resetting/overflow or interrupt or something along those lines. I guess the simple fix was to have the function check for a 0 duty cycle request and just force the output pin LOW.
Not a bug but the way the PWM works in the AVR. I don't have the manual, or time to chase that down, but it is written there (had that problem myself before).
Odd as it may seem...
Those are exactly the same thing:
#define HIGH 0x1
#define LOW 0x0 // <- same as 0
How do you have your LED hooked up? Is it inverted logic?
I think his question rather was to use the analogWrite or the digitalWrite function. ?
You are right. Some dyslexia there, I read two analogWrite(). Disregard my previous post.