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