/* ----------------------------------------------------------------
   candle_fade lights an LED connected to pin Digital 6
    -Uses Pulse-Width modulation to fade the LED
       
  Setup: Wire an LED from pin 6 through 330 ohm resistor to ground
  ----------------------------------------------------------------*/

int LEDpin = 6;                 // Variable for PWM pin number

void setup()
{
  pinMode(LEDpin, OUTPUT);      // sets pin for LED as output  
}

 void loop()  {                   // repeat forever
    for (int i = 0; i < 255; i++) {   // Fade up
        analogWrite(LEDpin, i);   //  PWM
        delay(5);
    }
   for (int i = 255; i > 0; i -= 1) { // Fade down
        analogWrite(LEDpin, i);   //  PWM
        delay(6);
    } 
  }  
