Thanks Billroy. That works. I had to add a line to constrain i to a maximum of 255.
int led = 3;
int i = 0;
long interval = 10;
long previousMillis = 0;
void setup()
{
Serial.begin (9600);
pinMode (led, OUTPUT);
}
void loop()
{
unsigned long currentMillis = millis();
if (currentMillis - previousMillis > interval) {
previousMillis = currentMillis;
i = min (i, 254); sets pwm to 255 maximum
analogWrite (led, i++);
Serial.println (i);
}
}
Although this works to turn the light on, I am still curious how to fix my origional code. Fading the light is just something I picked to try to get to understand the "blink without delay." That really was the origional question. I suppose the question is: how do I use the "blink without delay" with a for loop? Any ideas would be greatly appreciated