int LEDPin = 21;
void setup() {
// put your setup code here, to run once:
//You do not need to call pinMode() to set the pin for analogWrite()
}
void loop() {
// put your main code here, to run repeatedly:
int maxValue = 255;
for(int i = 0; i<maxValue; i++)
{
analogWrite(LEDPin, maxValue);
// delay(1000); why does adding a delay here remove the fade from led?
maxValue = maxValue - 1;
if(maxValue == 0)
{
for(int i = 0; i<255; i++)
{
analogWrite(LEDPin, maxValue);
// delay(100); and here?
maxValue = maxValue + 1;
}
}
}
}