FastLED 3.9.7
Loading...
Searching...
No Matches
Apa102.ino
1
2#include <Arduino.h>
3#include <FastLED.h>
4#include <lib8tion.h>
5
6#define NUM_LEDS 20
7
8#define STRIP_DATA_PIN 1
9#define STRIP_CLOCK_PIN 2
10
11CRGB leds[NUM_LEDS] = {0}; // Software gamma mode.
12
13void setup() {
14 delay(500); // power-up safety delay
15 // Two strips of LEDs, one in HD mode, one in software gamma mode.
16 FastLED.addLeds<APA102, STRIP_DATA_PIN, STRIP_CLOCK_PIN, RGB>(leds, NUM_LEDS);
17}
18
19uint8_t wrap_8bit(int i) {
20 // Modulo % operator here wraps a large "i" so that it is
21 // always in [0, 255] range when returned. For example, if
22 // "i" is 256, then this will return 0. If "i" is 257,
23 // then this will return 1. No matter how big the "i" is, the
24 // output range will always be [0, 255]
25 return i % 256;
26}
27
28void loop() {
29 // Draw a linear ramp of brightnesses to showcase the difference between
30 // the HD and non-HD mode.
31 for (int i = 0; i < NUM_LEDS; i++) {
32 uint8_t brightness = map(i, 0, NUM_LEDS - 1, 0, 255);
33 CRGB c(brightness, brightness, brightness); // Just make a shade of white.
34 leds[i] = c;
35 }
36 FastLED.show(); // All LEDs are now displayed.
37 delay(8); // Wait 8 milliseconds until the next frame.
38}
CFastLED FastLED
Global LED strip management instance.
Definition FastLED.cpp:45
central include file for FastLED, defines the CFastLED class/object
@ APA102
APA102 LED chipset.
Definition FastLED.h:101
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
@ RGB
Red, Green, Blue (0012)
Definition eorder.h:15
Fast, efficient 8-bit math functions specifically designed for high-performance LED programming.
Representation of an RGB pixel (Red, Green, Blue)
Definition crgb.h:54