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