Line | |
---|
1 |
|
---|
2 | /*
|
---|
3 | * Example of using the ChainableRGB library for controlling a Grove RGB.
|
---|
4 | * This code fades in an out colors in a strip of leds.
|
---|
5 | */
|
---|
6 |
|
---|
7 |
|
---|
8 | #include <ChainableLED.h>
|
---|
9 |
|
---|
10 | #define NUM_LEDS 5
|
---|
11 |
|
---|
12 | ChainableLED leds(7, 8, NUM_LEDS);
|
---|
13 |
|
---|
14 | void setup()
|
---|
15 | {
|
---|
16 | leds.init();
|
---|
17 | }
|
---|
18 |
|
---|
19 | byte power = 0;
|
---|
20 |
|
---|
21 | void loop()
|
---|
22 | {
|
---|
23 | for (byte i=0; i<NUM_LEDS; i++)
|
---|
24 | {
|
---|
25 | if (i%2 == 0)
|
---|
26 | leds.setColorRGB(i, power, 0, 0);
|
---|
27 | else
|
---|
28 | leds.setColorRGB(i, 0, 255-power, 0);
|
---|
29 | }
|
---|
30 | power+= 10;
|
---|
31 |
|
---|
32 | delay(10);
|
---|
33 | }
|
---|
34 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.