Line | |
---|
1 |
|
---|
2 | /*
|
---|
3 | * Example of using the ChainableRGB library for controlling a Grove RGB.
|
---|
4 | * This code cycles through all the colors in an uniform way. This is accomplished using a HSB color space.
|
---|
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 | float hue = 0.0;
|
---|
20 | boolean up = true;
|
---|
21 |
|
---|
22 | void loop()
|
---|
23 | {
|
---|
24 | for (byte i=0; i<NUM_LEDS; i++)
|
---|
25 | leds.setColorHSB(i, hue, 1.0, 0.5);
|
---|
26 |
|
---|
27 | delay(50);
|
---|
28 |
|
---|
29 | if (up)
|
---|
30 | hue+= 0.025;
|
---|
31 | else
|
---|
32 | hue-= 0.025;
|
---|
33 |
|
---|
34 | if (hue>=1.0 && up)
|
---|
35 | up = false;
|
---|
36 | else if (hue<=0.0 && !up)
|
---|
37 | up = true;
|
---|
38 | }
|
---|
39 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.