source: rtos_arduino/trunk/examples/NCESIoT_RTOS/ChainableLED/examples/CycleThroughColors/CycleThroughColors.ino@ 243

Last change on this file since 243 was 243, checked in by ertl-honda, 8 years ago

IoTパッケージの内容に合わせて更新

File size: 599 bytes
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
12ChainableLED leds(7, 8, NUM_LEDS);
13
14void setup()
15{
16 leds.init();
17}
18
19float hue = 0.0;
20boolean up = true;
21
22void 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.