File tree 1 file changed +25
-0
lines changed
1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change
1
+ int led = 9 ; // the pin that the LED is attached to
2
+ int brightness = 0 ; // how bright the LED is
3
+ int fadeAmount = 5 ; // how many points to fade the LED by
4
+
5
+ // the setup routine runs once when you press reset:
6
+ void setup () {
7
+ // declare pin 9 to be an output:
8
+ pinMode (led, OUTPUT);
9
+ }
10
+
11
+ // the loop routine runs over and over again forever:
12
+ void loop () {
13
+ // set the brightness of pin 9:
14
+ analogWrite (led, brightness);
15
+
16
+ // change the brightness for next time through the loop:
17
+ brightness = brightness + fadeAmount;
18
+
19
+ // reverse the direction of the fading at the ends of the fade:
20
+ if (brightness == 0 || brightness == 255 ) {
21
+ fadeAmount = -fadeAmount ;
22
+ }
23
+ // wait for 30 milliseconds to see the dimming effect
24
+ delay (30 );
25
+ }
You can’t perform that action at this time.
0 commit comments