Tutorial.Fading History

Show minor edits - Show changes to markup

May 02, 2012, at 03:41 AM by Scott Fitzgerald -
Changed line 25 from:
to:
November 16, 2011, at 04:11 AM by Scott Fitzgerald -
Changed line 25 from:
to:
September 30, 2011, at 03:11 AM by Scott Fitzgerald -
Changed line 25 from:
to:
September 23, 2010, at 10:33 PM by Christian Cerrito -
Changed lines 3-4 from:

Fading

to:

Fading

September 23, 2010, at 09:35 PM by Christian Cerrito -
Changed line 32 from:
to:
September 23, 2010, at 09:35 PM by Christian Cerrito -
Changed lines 31-33 from:
to:
September 23, 2010, at 09:30 PM by Christian Cerrito -
Changed lines 17-18 from:
to:
September 17, 2010, at 06:47 PM by Tom Igoe -
Changed lines 27-39 from:
to:
September 17, 2010, at 06:46 PM by Tom Igoe -
Changed lines 5-7 from:

Demonstrates the use of analog output (PWM) to fade an LED.

to:

Demonstrates the use of analog output (Pulse Width Modulation (PWM)) to fade an LED. PWM is a technique for getting an analog-like behavior from a digital output by switching it off and on very fast.

September 16, 2010, at 10:09 PM by Tom Igoe -
Changed line 25 from:
to:
September 16, 2010, at 10:09 PM by Tom Igoe -
Changed line 25 from:
to:
August 23, 2010, at 08:38 PM by Christian Cerrito -
Changed line 25 from:
to:
February 23, 2010, at 07:58 PM by Tom Igoe -
Changed lines 25-40 from:
 /*
  Fading
  
  This example shows how to fade an LED using the analogWrite() function.
  
  The circuit:
  * LED attached from digital pin 9 to ground.
  
  Created 1 Nov 2008
  By David A. Mellis
  Modified 17 June 2009
  By Tom Igoe
  
  http://arduino.cc/en/Tutorial/Fading
  
  */
to:
Deleted lines 26-52:
 int ledPin = 9;    // LED connected to digital pin 9

 void setup()  { 
   // nothing happens in setup 
 } 

 void loop()  { 
   // fade in from min to max in increments of 5 points:
   for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=5) { 
     // sets the value (range from 0 to 255):
     analogWrite(ledPin, fadeValue);         
     // wait for 30 milliseconds to see the dimming effect    
     delay(30);                            
   } 

   // fade out from max to min in increments of 5 points:
   for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=5) { 
     // sets the value (range from 0 to 255):
     analogWrite(ledPin, fadeValue);         
     // wait for 30 milliseconds to see the dimming effect    
     delay(30);                            
   } 
 }

August 27, 2009, at 08:46 PM by Tom Igoe -
Changed lines 19-20 from:
to:

image developed using Fritzing. For more circuit examples, see the Fritzing project page

July 05, 2009, at 07:21 PM by Tom Igoe -
Changed lines 22-25 from:

[@ /*

 Fading
to:
Deleted line 40:
 This example shows how to fade an LED using the analogWrite() function.
Changed lines 42-43 from:
 The circuit:
 * LED attached from digital pin 9 to ground.
to:
 int ledPin = 9;    // LED connected to digital pin 9
Changed lines 44-47 from:
 Created 1 Nov 2008
 By David A. Mellis
 Modified 17 June 2009
 By Tom Igoe
to:
 void setup()  { 
   // nothing happens in setup 
 } 
Changed lines 48-55 from:
 http://arduino.cc/en/Tutorial/Fading
to:
 void loop()  { 
   // fade in from min to max in increments of 5 points:
   for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=5) { 
     // sets the value (range from 0 to 255):
     analogWrite(ledPin, fadeValue);         
     // wait for 30 milliseconds to see the dimming effect    
     delay(30);                            
   } 
Changed lines 57-83 from:
 */

int ledPin = 9; // LED connected to digital pin 9

void setup() {

  // nothing happens in setup 

}

void loop() {

  // fade in from min to max in increments of 5 points:
  for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=5) { 
    // sets the value (range from 0 to 255):
    analogWrite(ledPin, fadeValue);         
    // wait for 30 milliseconds to see the dimming effect    
    delay(30);                            
  } 

  // fade out from max to min in increments of 5 points:
  for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=5) { 
    // sets the value (range from 0 to 255):
    analogWrite(ledPin, fadeValue);         
    // wait for 30 milliseconds to see the dimming effect    
    delay(30);                            
  } 

} @]

to:
June 25, 2009, at 11:31 PM by Tom Igoe -
Changed lines 17-20 from:
to:

June 25, 2009, at 11:31 PM by Tom Igoe -
Changed lines 17-20 from:
to:
June 25, 2009, at 11:31 PM by Tom Igoe -
Changed lines 7-12 from:

Circuit

An LED connected to pin 9 through an appropriate resistor (here 270 ohms).

to:

Circuit

An LED connected to digital output pin 9 through a 220-ohm resistor.

click the image to enlarge

Schematic

click the image to enlarge Attach:Dimmer_schem.png Δ Δ

June 17, 2009, at 11:28 PM by Tom Igoe -
Changed lines 16-17 from:

int value = 0; // variable to keep the actual value int ledpin = 9; // light connected to digital pin 9

to:

/*

 Fading
Changed lines 19-22 from:

void setup() {

  // nothing for setup 

}

to:
 This example shows how to fade an LED using the analogWrite() function.
Changed lines 21-26 from:

void loop() {

  for(value = 0 ; value <= 255; value+=5) // fade in (from min to max) 
  { 
    analogWrite(ledpin, value);           // sets the value (range from 0 to 255) 
    delay(30);                            // waits for 30 milli seconds to see the dimming effect 
to:
 The circuit:
 * LED attached from digital pin 9 to ground.

 Created 1 Nov 2008
 By David A. Mellis
 Modified 17 June 2009
 By Tom Igoe

 http://arduino.cc/en/Tutorial/Fading

 */

int ledPin = 9; // LED connected to digital pin 9

void setup() {

  // nothing happens in setup 

}

void loop() {

  // fade in from min to max in increments of 5 points:
  for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=5) { 
    // sets the value (range from 0 to 255):
    analogWrite(ledPin, fadeValue);         
    // wait for 30 milliseconds to see the dimming effect    
    delay(30);                            
Changed lines 48-52 from:
  for(value = 255; value >=0; value-=5)   // fade out (from max to min) 
  { 
    analogWrite(ledpin, value); 
    delay(30); 
  }  
to:
  // fade out from max to min in increments of 5 points:
  for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=5) { 
    // sets the value (range from 0 to 255):
    analogWrite(ledPin, fadeValue);         
    // wait for 30 milliseconds to see the dimming effect    
    delay(30);                            
  } 
November 01, 2008, at 11:34 PM by David A. Mellis -
Changed lines 9-10 from:

An LED connected to digital pin 9.

to:

An LED connected to pin 9 through an appropriate resistor (here 270 ohms).

March 26, 2007, at 01:54 PM by David A. Mellis -
Added lines 5-6:

Demonstrates the use of analog output (PWM) to fade an LED.

Added lines 9-10:

An LED connected to digital pin 9.

March 26, 2007, at 01:52 PM by David A. Mellis -
Added lines 1-31:

Examples > Analog I/O

Fading

Circuit

Code

int value = 0;                            // variable to keep the actual value 
int ledpin = 9;                           // light connected to digital pin 9

void setup() 
{ 
  // nothing for setup 
} 

void loop() 
{ 
  for(value = 0 ; value <= 255; value+=5) // fade in (from min to max) 
  { 
    analogWrite(ledpin, value);           // sets the value (range from 0 to 255) 
    delay(30);                            // waits for 30 milli seconds to see the dimming effect 
  } 
  for(value = 255; value >=0; value-=5)   // fade out (from max to min) 
  { 
    analogWrite(ledpin, value); 
    delay(30); 
  }  
}

Share