FastLED 3.9.15
Loading...
Searching...
No Matches
Cylon.ino
Go to the documentation of this file.
1
5
6#include <FastLED.h>
7
8// How many leds in your strip?
9#define NUM_LEDS 64
10
11// For led chips like Neopixels, which have a data line, ground, and power, you just
12// need to define DATA_PIN. For led chipsets that are SPI based (four wires - data, clock,
13// ground, and power), like the LPD8806, define both DATA_PIN and CLOCK_PIN
14#define DATA_PIN 2
15#define CLOCK_PIN 13
16
17// Define the array of leds
19
20void setup() {
21 Serial.begin(57600);
22 Serial.println("resetting");
23 FastLED.addLeds<WS2812,DATA_PIN,RGB>(leds,NUM_LEDS);
24 FastLED.setBrightness(84);
25}
26
27void fadeall() { for(int i = 0; i < NUM_LEDS; i++) { leds[i].nscale8(250); } }
28
29void loop() {
30 static uint8_t hue = 0;
31 Serial.print("x");
32 // First slide the led in one direction
33 for(int i = 0; i < NUM_LEDS; i++) {
34 // Set the i'th led to red
35 leds[i] = CHSV(hue++, 255, 255);
36 // Show the leds
37 FastLED.show();
38 // now that we've shown the leds, reset the i'th led to black
39 // leds[i] = CRGB::Black;
40 fadeall();
41 // Wait a little bit before we loop around and do it again
42 delay(10);
43 }
44 Serial.print("x");
45
46 // Now go in the other direction.
47 for(int i = (NUM_LEDS)-1; i >= 0; i--) {
48 // Set the i'th led to red
49 leds[i] = CHSV(hue++, 255, 255);
50 // Show the leds
51 FastLED.show();
52 // now that we've shown the leds, reset the i'th led to black
53 // leds[i] = CRGB::Black;
54 fadeall();
55 // Wait a little bit before we loop around and do it again
56 delay(10);
57 }
58}
void setup()
void loop()
#define NUM_LEDS
fl::CRGB leds[NUM_LEDS]
#define DATA_PIN
Definition ClientReal.h:82
void fadeall()
Definition Cylon.ino:27
FL_DISABLE_WARNING_PUSH FL_DISABLE_WARNING_GLOBAL_CONSTRUCTORS CFastLED FastLED
Global LED strip management instance.
uint8_t hue
Definition advanced.h:94
constexpr EOrder RGB
Definition eorder.h:17
fl::hsv8 CHSV
Definition chsv.h:11
fl::CRGB CRGB
Definition crgb.h:25
#define Serial
Definition serial.h:304