~ubuntu-branches/debian/experimental/arduino/experimental

« back to all changes in this revision

Viewing changes to build/shared/examples/3.Analog/Fading/Fading.pde

  • Committer: Package Import Robot
  • Author(s): Scott Howard
  • Date: 2012-03-11 18:19:42 UTC
  • mfrom: (1.1.5) (5.1.14 sid)
  • Revision ID: package-import@ubuntu.com-20120311181942-be2clnbz1gcehixb
Tags: 1:1.0.1~rc1+dfsg-1
New upstream release, experimental.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 Fading
3
 
 
4
 
 This example shows how to fade an LED using the analogWrite() function.
5
 
 
6
 
 The circuit:
7
 
 * LED attached from digital pin 9 to ground.
8
 
 
9
 
 Created 1 Nov 2008
10
 
 By David A. Mellis
11
 
 Modified 17 June 2009
12
 
 By Tom Igoe
13
 
 
14
 
 http://arduino.cc/en/Tutorial/Fading
15
 
 
16
 
 This example code is in the public domain.
17
 
 
18
 
 */
19
 
 
20
 
 
21
 
int ledPin = 9;    // LED connected to digital pin 9
22
 
 
23
 
void setup()  { 
24
 
  // nothing happens in setup 
25
 
26
 
 
27
 
void loop()  { 
28
 
  // fade in from min to max in increments of 5 points:
29
 
  for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=5) { 
30
 
    // sets the value (range from 0 to 255):
31
 
    analogWrite(ledPin, fadeValue);         
32
 
    // wait for 30 milliseconds to see the dimming effect    
33
 
    delay(30);                            
34
 
  } 
35
 
 
36
 
  // fade out from max to min in increments of 5 points:
37
 
  for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=5) { 
38
 
    // sets the value (range from 0 to 255):
39
 
    analogWrite(ledPin, fadeValue);         
40
 
    // wait for 30 milliseconds to see the dimming effect    
41
 
    delay(30);                            
42
 
  } 
43
 
}
44
 
 
45