FastLED 3.7.8
Loading...
Searching...
No Matches
Cylon.ino
Go to the documentation of this file.
1
4
5#include <FastLED.h>
6
7// How many leds in your strip?
8#define NUM_LEDS 64
9
10// For led chips like Neopixels, which have a data line, ground, and power, you just
11// need to define DATA_PIN. For led chipsets that are SPI based (four wires - data, clock,
12// ground, and power), like the LPD8806, define both DATA_PIN and CLOCK_PIN
13#define DATA_PIN 2
14#define CLOCK_PIN 13
15
16// Define the array of leds
17CRGB leds[NUM_LEDS];
18
19void setup() {
20 Serial.begin(57600);
21 Serial.println("resetting");
22 FastLED.addLeds<WS2812,DATA_PIN,RGB>(leds,NUM_LEDS);
24}
25
26void fadeall() { for(int i = 0; i < NUM_LEDS; i++) { leds[i].nscale8(250); } }
27
28void loop() {
29 static uint8_t hue = 0;
30 Serial.print("x");
31 // First slide the led in one direction
32 for(int i = 0; i < NUM_LEDS; i++) {
33 // Set the i'th led to red
34 leds[i] = CHSV(hue++, 255, 255);
35 // Show the leds
36 FastLED.show();
37 // now that we've shown the leds, reset the i'th led to black
38 // leds[i] = CRGB::Black;
39 fadeall();
40 // Wait a little bit before we loop around and do it again
41 delay(10);
42 }
43 Serial.print("x");
44
45 // Now go in the other direction.
46 for(int i = (NUM_LEDS)-1; i >= 0; i--) {
47 // Set the i'th led to red
48 leds[i] = CHSV(hue++, 255, 255);
49 // Show the leds
50 FastLED.show();
51 // now that we've shown the leds, reset the i'th led to black
52 // leds[i] = CRGB::Black;
53 fadeall();
54 // Wait a little bit before we loop around and do it again
55 delay(10);
56 }
57}
CFastLED FastLED
Global LED strip management instance.
Definition FastLED.cpp:21
central include file for FastLED, defines the CFastLED class/object
void setBrightness(uint8_t scale)
Set the global brightness scaling.
Definition FastLED.h:715
void show(uint8_t scale)
Update all our controllers with the current led colors, using the passed in brightness.
Definition FastLED.cpp:59
static CLEDController & addLeds(CLEDController *pLed, struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0)
Add a CLEDController instance to the world.
Definition FastLED.cpp:47
WS2812 controller class.
Definition FastLED.h:186
FASTLED_FORCE_INLINE CRGB & nscale8(uint8_t scaledown)
Scale down a RGB to N/256ths of its current brightness, using "plain math" dimming rules.
Definition crgb.hpp:72
Representation of an HSV pixel (hue, saturation, value (aka brightness)).
Definition chsv.h:11
Representation of an RGB pixel (Red, Green, Blue)
Definition crgb.h:25