AnalogWrite() not working

Anyone having trouble with analogWrite? The following code produces a blinking LED, but no fading:

int value = 0; // variable to keep the actual value
int pin = 13; // light connected to analog pin 0

void setup()
{
// nothing for setup

}

void loop()
{
for(value = 0 ; value <= 255; value+=1) // fade in (from min to max)
{
analogWrite(pin, value); // sets the value (range from 0 to 255)
delay(30); // waits for 30 milli seconds to see the dimming effect
}
delay(500);
}

PWM works but only on certain pins (the ones connected to timers)

in this case 9 and 10 have pwm capability

all other pins have this function that turns the pin on if the value is more than 128

--
Update

the new design for the arduino board that i will be publishing soon has clearly indicated which ones are the PWM pins

Sry, i need write first post. Then i can link my blog in exhibition forum. ::slight_smile:

Massimo, I think I can help. Be sure to use a current limiting resistor on your LED. Pins 3,5,6, and 11 also have PWM capability.

Massimo, I think I can help. Be sure to use a current limiting resistor on your LED. Pins 3,5,6, and 11 also have PWM capability.

I suspect that Massimo figured out sense the six year old posting was made. That or he is the most patient man in the world. ;D

Lefty

I suspect that Massimo figured out sense the six year old posting was made.

That and the very next post explains the situation. Seems like a trend lately. People read post #1 and ignore the rest.