]> git.piffa.net Git - sketchbook_andrea/blob - basic/simplest_pwm_byte/simplest_pwm_byte.ino
fc7658de9340b89557c5cf071291672265457567
[sketchbook_andrea] / basic / simplest_pwm_byte / simplest_pwm_byte.ino
1 /*
2  Fade
3  
4  This example shows how to fade an LED on pin 9
5  using the analogWrite() function.
6  
7  This example code is in the public domain.
8  */
9
10 byte led  = 9   ;        // the pin that the LED is attached to
11
12 byte brightness = 0;    // how bright the LED is
13
14 // the setup routine runs once when you press reset:
15 void setup()  { 
16   // declare pin 9 to be an output:
17   pinMode(led, OUTPUT);
18
19
20 // the loop routine runs over and over again forever:
21 void loop()  { 
22   // set the brightness of pin 9:
23   analogWrite(led, brightness++);    
24   delay(10);       
25 }
26
27