<!-- language-all: c -->
according to the links you provide of the arduino.cc forum the question is more or less answered. If not that important, just avoid `analogWrite(led,0)` and make it `analogWrite(led,1)`
if you still want that analogWrite 0, I've tested your code with the advices and seems to work ok changing the register manually:
#include "wiring_private.h"
int led = 11;
int brightness = 0;
void setup()
{
pinMode(led, OUTPUT);
}
void loop()
{
if (brightness >= 256) //checks if brightness has passed 255, resets to 0
{
brightness = 0;
sbi(TCCR2A, COM2A1);
OCR2A = 0; // set pwm duty
}
analogWrite(led, brightness);
if (brightness == 0)
{
delay(1000); //LED off for 1 second
}
brightness += 1; //increment brightness
delay(20);
}