/* fade_example.pde This example shows how to fade an LED using the analogWrite() function. BJFurman 02APR2010 based on Fading Created 1 Nov 2008 By David A. Mellis Modified 17 June 2009 By Tom Igoe http://arduino.cc/en/Tutorial/Fading */ const byte ledPin = 3; // red RGB LED on Experimenter const byte FADE_MAX = 255; // max value for setting duty cycle const byte FADE_INC = 5; // increment for changing duty cycle void setup() { Serial.begin(9600); pinMode(ledPin, OUTPUT); } void loop() { // fade in from min to max in increments of 5 points: int fadeValue; for(fadeValue = 0 ; fadeValue <= FADE_MAX; fadeValue +=FADE_INC) { analogWrite(ledPin, fadeValue); Serial.print("fading in value = "); Serial.println(fadeValue); } // fade out from max to min in increments of 5 points: for(fadeValue = FADE_MAX ; fadeValue >= 0; fadeValue -=FADE_INC) { analogWrite(ledPin, fadeValue); Serial.print("fading out value = "); Serial.println(fadeValue); } }