Tutorial.Fading History

Hide minor edits - Show changes to output

May 02, 2012, at 03:41 AM by Scott Fitzgerald -
Changed line 25 from:
(:source http://arduino.cc/en/pub/code/master/build/shared/examples/3.Analog/Fading/Fading.ino lang=arduino tabwidth=4:)
to:
(:source http://arduino.cc/en/pub/code/master/build/shared/examples/03.Analog/Fading/Fading.ino lang=arduino tabwidth=4:)
November 16, 2011, at 04:11 AM by Scott Fitzgerald -
Changed line 25 from:
(:source http://arduino.cc/en/pub/code/new-extension/build/shared/examples/3.Analog/Fading/Fading.ino lang=arduino tabwidth=4:)
to:
(:source http://arduino.cc/en/pub/code/master/build/shared/examples/3.Analog/Fading/Fading.ino lang=arduino tabwidth=4:)
September 30, 2011, at 03:11 AM by Scott Fitzgerald -
Changed line 25 from:
(:source http://arduino.cc/en/pub/code/master/build/shared/examples/3.Analog/Fading/Fading.pde lang=arduino tabwidth=4:)
to:
(:source http://arduino.cc/en/pub/code/new-extension/build/shared/examples/3.Analog/Fading/Fading.ino lang=arduino tabwidth=4:)
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:
* [[Reference/analogWead]]()
to:
* [[Reference/analogWrite]]()
September 23, 2010, at 09:35 PM by Christian Cerrito -
Changed lines 31-33 from:
* [[Reference/pinMode]]()
* [[Reference/analogRead]]()
* [[Reference/digitalWrite]]()
to:
* [[Reference/for]]()
* [[Reference/analogWead]]()
September 23, 2010, at 09:30 PM by Christian Cerrito -
Changed lines 17-18 from:
%width=400px%[[Attach:dimmer_schem.png |Attach:dimmer_schem.png]]
to:
%width=400px%[[Attach:fading_schem.png |Attach:fading_schem.png]]
September 17, 2010, at 06:47 PM by Tom Igoe -
Changed lines 27-39 from:
(:divend:)
to:
(:divend:)


!!!See Also:
* [[Reference/pinMode]]()
* [[Reference/analogRead]]()
* [[Reference/digitalWrite]]()
* [[Reference/delay]]()

* [[Tutorial/AnalogReadSerial]] - read a potentiometer, print its state to the serial monitor
* [[Tutorial/AnalogInOutSerial]] - read an analog input, map its values, and then use that information to dim or brighten an LED.
* [[Tutorial/Fade]] - use an analog input to fade an LED
* [[Tutorial/Calibration]] - calibrating analog sensor readings
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 ([[PWM|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:
(:source http://arduino.cc/en/pub/code/master/build/shared/examples/3.Analog/Fading/Fading.pde lang=arduino tabwidth=4:)
to:
(:source http://arduino.cc/en/pub/code/master/build/shared/examples/3.Analog/Fading/Fading.pde lang=arduino tabwidth=4:)
September 16, 2010, at 10:09 PM by Tom Igoe -
Changed line 25 from:
(:source http://arduino.cc/en/pub/code/master/build/shared/examples/3.Analog/Fading/Fading.pde language=arduino tabwidth=4:)
to:
(:source http://arduino.cc/en/pub/code/master/build/shared/examples/3.Analog/Fading/Fading.pde lang=arduino tabwidth=4:)
August 23, 2010, at 08:38 PM by Christian Cerrito -
Changed line 25 from:
(:source http://arduino.cc/en/pub/code/master/build/shared/examples/Analog/Fading/Fading.pde language=arduino tabwidth=4:)
to:
(:source http://arduino.cc/en/pub/code/master/build/shared/examples/3.Analog/Fading/Fading.pde language=arduino tabwidth=4:)
February 23, 2010, at 07:58 PM by Tom Igoe -
Changed lines 25-40 from:
%color=#7e7e7e%/*
%color=#7e7e7e% Fading
%color=#7e7e7e%
%color=#7e7e7e% This example shows how to fade an LED using the analogWrite() function.
%color=#7e7e7e%
%color=#7e7e7e% The circuit:
%color=#7e7e7e% * LED attached from digital pin 9 to ground.
%color=#7e7e7e%
%color=#7e7e7e% Created 1 Nov 2008
%color=#7e7e7e% By David A. Mellis
%color=#7e7e7e% Modified 17 June 2009
%color=#7e7e7e% By Tom Igoe
%color=#7e7e7e%
%color=#7e7e7e% http://arduino.cc/en/Tutorial/Fading
%color=#7e7e7e%
%color=#7e7e7e% */
to:
(:source http://arduino.cc/en/pub/code/master/build/shared/examples/Analog/Fading/Fading.pde language=arduino tabwidth=4:)
Deleted lines 26-52:

%color=#cc6600%int%% ledPin = 9; %color=#7e7e7e%// LED connected to digital pin 9

%color=#cc6600%void%% %color=#cc6600%'''setup'''%%() {
%color=#7e7e7e%// nothing happens in setup
}

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

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


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

to:
[-image developed using [[http://www.fritzing.org |Fritzing]]. For more circuit examples, see the [[http://fritzing.org/projects/|Fritzing project page]] -]

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

[@
/*
Fading
to:
(:div class=code :)

%color=#7e7e7e%/*
%color=#7e7e7e% Fading
%color=#7e7e7e%
%color=#7e7e7e% This example shows how to fade an LED using the analogWrite() function.
%color=#7e7e7e%
%color=#7e7e7e% The circuit:
%color=#7e7e7e% * LED attached from digital pin 9 to ground.
%color=#7e7e7e%
%color=#7e7e7e% Created 1 Nov 2008
%color=#7e7e7e% By David A. Mellis
%color=#7e7e7e% Modified 17 June 2009
%color=#7e7e7e% By Tom Igoe
%color=#7e7e7e%
%color=#7e7e7e% http://arduino.cc/en/Tutorial/Fading
%color=#7e7e7e%
%color=#7e7e7e% */
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:
%color=#cc6600%int%% ledPin = 9; %color=#7e7e7e%// 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:
%color=#cc6600%void%% %color=#cc6600%'''setup'''%%() {
%color=#7e7e7e%// nothing happens in setup
}
Changed lines 48-55 from:
http://arduino.cc/en/Tutorial/Fading
to:
%color=#cc6600%void%% %color=#cc6600%'''loop'''%%() {
%color=#7e7e7e%// fade in from min to max in increments of 5 points:
%color=#cc6600%for%%(%color=#cc6600%int%% fadeValue = 0 ; fadeValue <= 255; fadeValue +=5) {
%color=#7e7e7e%// sets the value (range from 0 to 255):
%color=#cc6600%analogWrite%%(ledPin, fadeValue);
%color=#7e7e7e%// wait for 30 milliseconds to see the dimming effect
%color=#cc6600%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:
%color=#7e7e7e%// fade out from max to min in increments of 5 points:
%color=#cc6600%for%%(%color=#cc6600%int%% fadeValue = 255 ; fadeValue >= 0; fadeValue -=5) {
%color=#7e7e7e%// sets the value (range from 0 to 255):
%color=#cc6600%analogWrite%%(ledPin, fadeValue);
%color=#7e7e7e%// wait for 30 milliseconds to see the dimming effect
%color=#cc6600%delay%%(30);
}
}



(:divend:)
June 25, 2009, at 11:31 PM by Tom Igoe -
Changed lines 17-20 from:
%width=400px%[[Attach:Dimmer_schem2.png |Attach:Dimmer_schem2.png]]


to:
%width=400px%[[Attach:dimmer_schem.png |Attach:dimmer_schem.png]]


June 25, 2009, at 11:31 PM by Tom Igoe -
Changed lines 17-20 from:
%width=400px%[[Attach:Dimmer_schem.png |Attach:Dimmer_schem.png]]


to:
%width=400px%[[Attach:Dimmer_schem2.png |Attach:Dimmer_schem2.png]]


June 25, 2009, at 11:31 PM by Tom Igoe -
Changed lines 7-12 from:
!!!Circuit

Attach:Fading.jpg

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-]
%width=400px%[[Attach:dimmer-circuit3.png |Attach:dimmer-circuit3.png]]

!!!Schematic

[-click the image to enlarge-]
%width=400px%[[Attach:Dimmer_schem.png |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:
Attach:Fading.jpg

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