FastLED 3.9.3
Loading...
Searching...
No Matches
FirstLight.ino
Go to the documentation of this file.
1
4
5// Use if you want to force the software SPI subsystem to be used for some reason (generally, you don't)
6// #define FASTLED_FORCE_SOFTWARE_SPI
7// Use if you want to force non-accelerated pin access (hint: you really don't, it breaks lots of things)
8// #define FASTLED_FORCE_SOFTWARE_SPI
9// #define FASTLED_FORCE_SOFTWARE_PINS
10#include <FastLED.h>
11
13//
14// Move a white dot along the strip of leds. This program simply shows how to configure the leds,
15// and then how to turn a single pixel white and then off, moving down the line of pixels.
16//
17
18// How many leds are in the strip?
19#define NUM_LEDS 60
20
21// For led chips like WS2812, which have a data line, ground, and power, you just
22// need to define DATA_PIN. For led chipsets that are SPI based (four wires - data, clock,
23// ground, and power), like the LPD8806 define both DATA_PIN and CLOCK_PIN
24// Clock pin only needed for SPI based chipsets when not using hardware SPI
25#define DATA_PIN 3
26#define CLOCK_PIN 13
27
28// This is an array of leds. One item for each led in your strip.
29CRGB leds[NUM_LEDS];
30
31// This function sets up the ledsand tells the controller about them
32void setup() {
33 // sanity check delay - allows reprogramming if accidently blowing power w/leds
34 delay(2000);
35
36 // Uncomment/edit one of the following lines for your leds arrangement.
37 // ## Clockless types ##
38 // FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS); // GRB ordering is assumed
39 // FastLED.addLeds<SM16703, DATA_PIN, RGB>(leds, NUM_LEDS);
40 // FastLED.addLeds<TM1829, DATA_PIN, RGB>(leds, NUM_LEDS);
41 // FastLED.addLeds<TM1812, DATA_PIN, RGB>(leds, NUM_LEDS);
42 // FastLED.addLeds<TM1809, DATA_PIN, RGB>(leds, NUM_LEDS);
43 // FastLED.addLeds<TM1804, DATA_PIN, RGB>(leds, NUM_LEDS);
44 // FastLED.addLeds<TM1803, DATA_PIN, RGB>(leds, NUM_LEDS);
45 // FastLED.addLeds<UCS1903, DATA_PIN, RGB>(leds, NUM_LEDS);
46 // FastLED.addLeds<UCS1903B, DATA_PIN, RGB>(leds, NUM_LEDS);
47 // FastLED.addLeds<UCS1904, DATA_PIN, RGB>(leds, NUM_LEDS);
48 // FastLED.addLeds<UCS2903, DATA_PIN, RGB>(leds, NUM_LEDS);
49 // FastLED.addLeds<WS2812, DATA_PIN, RGB>(leds, NUM_LEDS); // GRB ordering is typical
50 // FastLED.addLeds<WS2852, DATA_PIN, RGB>(leds, NUM_LEDS); // GRB ordering is typical
51 // FastLED.addLeds<WS2812B, DATA_PIN, RGB>(leds, NUM_LEDS); // GRB ordering is typical
52 // FastLED.addLeds<GS1903, DATA_PIN, RGB>(leds, NUM_LEDS);
53 // FastLED.addLeds<SK6812, DATA_PIN, RGB>(leds, NUM_LEDS); // GRB ordering is typical
54 // FastLED.addLeds<SK6822, DATA_PIN, RGB>(leds, NUM_LEDS);
55 // FastLED.addLeds<APA106, DATA_PIN, RGB>(leds, NUM_LEDS);
56 // FastLED.addLeds<PL9823, DATA_PIN, RGB>(leds, NUM_LEDS);
57 // FastLED.addLeds<SK6822, DATA_PIN, RGB>(leds, NUM_LEDS);
58 FastLED.addLeds<WS2811, DATA_PIN, RGB>(leds, NUM_LEDS);
59 // FastLED.addLeds<WS2813, DATA_PIN, RGB>(leds, NUM_LEDS);
60 // FastLED.addLeds<APA104, DATA_PIN, RGB>(leds, NUM_LEDS);
61 // FastLED.addLeds<WS2811_400, DATA_PIN, RGB>(leds, NUM_LEDS);
62 // FastLED.addLeds<GE8822, DATA_PIN, RGB>(leds, NUM_LEDS);
63 // FastLED.addLeds<GW6205, DATA_PIN, RGB>(leds, NUM_LEDS);
64 // FastLED.addLeds<GW6205_400, DATA_PIN, RGB>(leds, NUM_LEDS);
65 // FastLED.addLeds<LPD1886, DATA_PIN, RGB>(leds, NUM_LEDS);
66 // FastLED.addLeds<LPD1886_8BIT, DATA_PIN, RGB>(leds, NUM_LEDS);
67 // ## Clocked (SPI) types ##
68 // FastLED.addLeds<LPD6803, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS); // GRB ordering is typical
69 // FastLED.addLeds<LPD8806, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS); // GRB ordering is typical
70 // FastLED.addLeds<WS2801, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
71 // FastLED.addLeds<WS2803, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
72 // FastLED.addLeds<SM16716, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
73 // FastLED.addLeds<P9813, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS); // BGR ordering is typical
74 // FastLED.addLeds<DOTSTAR, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS); // BGR ordering is typical
75 // FastLED.addLeds<APA102, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS); // BGR ordering is typical
76 // FastLED.addLeds<SK9822, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS); // BGR ordering is typical
77}
78
79// This function runs over and over, and is where you do the magic to light
80// your leds.
81void loop() {
82 // Move a single white led
83 for(int whiteLed = 0; whiteLed < NUM_LEDS; whiteLed = whiteLed + 1) {
84 // Turn our current led on to white, then show the leds
85 leds[whiteLed] = CRGB::White;
86
87 // Show the leds (only one of which is set to white, from above)
88 FastLED.show();
89
90 // Wait a little bit
91 delay(100);
92
93 // Turn our current led back to black for the next loop around
94 leds[whiteLed] = CRGB::Black;
95 }
96}
CFastLED FastLED
Global LED strip management instance.
Definition FastLED.cpp:33
central include file for FastLED, defines the CFastLED class/object
void show(uint8_t scale)
Update all our controllers with the current led colors, using the passed in brightness.
Definition FastLED.cpp:82
static CLEDController & addLeds(CLEDController *pLed, struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0)
Add a CLEDController instance to the world.
Definition FastLED.cpp:67
WS2811 controller class.
Definition FastLED.h:233
@ White
Definition crgb.h:615
@ Black
Definition crgb.h:479
Representation of an RGB pixel (Red, Green, Blue)
Definition crgb.h:39