|
1 |
| -#include <Adafruit_DotStar.h> |
2 |
| - |
3 |
| -// LEDs! |
4 |
| -Adafruit_DotStar pixels(NUM_DOTSTAR, PIN_DOTSTAR_DATA, PIN_DOTSTAR_CLOCK, DOTSTAR_BRG); |
5 |
| - |
6 |
| -uint16_t firstPixelHue = 0; |
7 |
| -uint8_t LED_dutycycle = 0; |
8 |
| - |
9 |
| -void setup() { |
10 |
| - Serial.begin(115200); |
11 |
| - |
12 |
| - pinMode(LED_BUILTIN, OUTPUT); |
13 |
| - |
14 |
| - ledcSetup(0, 5000, 8); |
15 |
| - ledcAttachPin(LED_BUILTIN, 0); |
16 |
| - |
17 |
| - pixels.begin(); // Initialize pins for output |
18 |
| - pixels.show(); // Turn all LEDs off ASAP |
19 |
| - pixels.setBrightness(20); |
20 |
| -} |
21 |
| - |
22 |
| - |
23 |
| - |
24 |
| -void loop() { |
25 |
| - Serial.println("Hello!"); |
26 |
| - |
27 |
| - // pulse red LED |
28 |
| - ledcWrite(0, LED_dutycycle++); |
29 |
| - |
30 |
| - // rainbow dotstars |
31 |
| - for (int i=0; i<pixels.numPixels(); i++) { // For each pixel in strip... |
32 |
| - int pixelHue = firstPixelHue + (i * 65536L / pixels.numPixels()); |
33 |
| - pixels.setPixelColor(i, pixels.gamma32(pixels.ColorHSV(pixelHue))); |
34 |
| - } |
35 |
| - pixels.show(); // Update strip with new contents |
36 |
| - firstPixelHue += 256; |
37 |
| - |
38 |
| - delay(15); |
39 |
| -} |
40 |
| - |
41 |
| - |
42 |
| -void rainbow(int wait) { |
43 |
| - for(long firstPixelHue = 0; firstPixelHue < 5*65536; firstPixelHue += 256) { |
44 |
| - for(int i=0; i<pixels.numPixels(); i++) { // For each pixel in strip... |
45 |
| - int pixelHue = firstPixelHue + (i * 65536L / pixels.numPixels()); |
46 |
| - pixels.setPixelColor(i, pixels.gamma32(pixels.ColorHSV(pixelHue))); |
47 |
| - } |
48 |
| - pixels.show(); // Update strip with new contents |
49 |
| - delay(wait); // Pause for a moment |
50 |
| - } |
51 |
| -} |
| 1 | +#include <Adafruit_DotStar.h> |
| 2 | + |
| 3 | +#define NUM_DOTSTAR 5 |
| 4 | + |
| 5 | +// LEDs! |
| 6 | +Adafruit_DotStar pixels(NUM_DOTSTAR, PIN_DOTSTAR_DATA, PIN_DOTSTAR_CLOCK, DOTSTAR_BRG); |
| 7 | + |
| 8 | +uint16_t firstPixelHue = 0; |
| 9 | +uint8_t LED_dutycycle = 0; |
| 10 | + |
| 11 | +void setup() { |
| 12 | + Serial.begin(115200); |
| 13 | + |
| 14 | + pinMode(LED_BUILTIN, OUTPUT); |
| 15 | + |
| 16 | + ledcSetup(0, 5000, 8); |
| 17 | + ledcAttachPin(LED_BUILTIN, 0); |
| 18 | + |
| 19 | + pixels.begin(); // Initialize pins for output |
| 20 | + pixels.show(); // Turn all LEDs off ASAP |
| 21 | + pixels.setBrightness(20); |
| 22 | +} |
| 23 | + |
| 24 | + |
| 25 | + |
| 26 | +void loop() { |
| 27 | + Serial.println("Hello!"); |
| 28 | + |
| 29 | + // pulse red LED |
| 30 | + ledcWrite(0, LED_dutycycle++); |
| 31 | + |
| 32 | + // rainbow dotstars |
| 33 | + for (int i=0; i<pixels.numPixels(); i++) { // For each pixel in strip... |
| 34 | + int pixelHue = firstPixelHue + (i * 65536L / pixels.numPixels()); |
| 35 | + pixels.setPixelColor(i, pixels.gamma32(pixels.ColorHSV(pixelHue))); |
| 36 | + } |
| 37 | + pixels.show(); // Update strip with new contents |
| 38 | + firstPixelHue += 256; |
| 39 | + |
| 40 | + delay(15); |
| 41 | +} |
| 42 | + |
| 43 | + |
| 44 | +void rainbow(int wait) { |
| 45 | + for(long firstPixelHue = 0; firstPixelHue < 5*65536; firstPixelHue += 256) { |
| 46 | + for(int i=0; i<pixels.numPixels(); i++) { // For each pixel in strip... |
| 47 | + int pixelHue = firstPixelHue + (i * 65536L / pixels.numPixels()); |
| 48 | + pixels.setPixelColor(i, pixels.gamma32(pixels.ColorHSV(pixelHue))); |
| 49 | + } |
| 50 | + pixels.show(); // Update strip with new contents |
| 51 | + delay(wait); // Pause for a moment |
| 52 | + } |
| 53 | +} |
0 commit comments