1/* 2 Fading 3 fading an LED slowly on and off again 4 5 This example is part of the Fritzing Creator Kit: www.fritzing.org/creator-kit. 6*/ 7 8int ledPin = 9; // ledPin is declared 9 10void setup(){ 11 // no need to declare the analog output in the setup 12} 13 14void loop(){ 15 for(int fadeValue = 0; fadeValue <= 255; fadeValue += 5) { // fadeValue is counted up in steps of five 16 analogWrite(ledPin, fadeValue); // and sent to the led as an analog value 17 delay(2); // short stop 18 } 19 for(int fadeValue = 255; fadeValue >= 0; fadeValue -= 5) { // fadeValue is counted down in steps of five 20 analogWrite(ledPin, fadeValue); // and sent to the led as an analog value 21 delay(2); // short stop 22 } 23} 24 25 26