FastLED
3.9.15
Loading...
Searching...
No Matches
Apa102.ino
Go to the documentation of this file.
1
// @filter: (board is not stm32f103cb)
2
3
#include <
Arduino.h
>
4
#include <FastLED.h>
5
#include <
lib8tion.h
>
6
7
#define NUM_LEDS 20
8
9
#define STRIP_DATA_PIN 1
10
#define STRIP_CLOCK_PIN 2
11
12
CRGB
leds
[
NUM_LEDS
] = {0};
// Software gamma mode.
13
14
void
setup
() {
15
delay(500);
// power-up safety delay
16
// Two strips of LEDs, one in HD mode, one in software gamma mode.
17
FastLED
.addLeds<
APA102
,
STRIP_DATA_PIN
,
STRIP_CLOCK_PIN
,
RGB
>(
leds
,
NUM_LEDS
);
18
}
19
20
uint8_t
wrap_8bit
(
int
i) {
21
// Modulo % operator here wraps a large "i" so that it is
22
// always in [0, 255] range when returned. For example, if
23
// "i" is 256, then this will return 0. If "i" is 257,
24
// then this will return 1. No matter how big the "i" is, the
25
// output range will always be [0, 255]
26
return
i % 256;
27
}
28
29
void
loop
() {
30
// Draw a linear ramp of brightnesses to showcase the difference between
31
// the HD and non-HD mode.
32
for
(
int
i = 0; i <
NUM_LEDS
; i++) {
33
uint8_t
brightness
= map(i, 0,
NUM_LEDS
- 1, 0, 255);
34
CRGB
c(
brightness
,
brightness
,
brightness
);
// Just make a shade of white.
35
leds
[i] = c;
36
}
37
FastLED
.show();
// All LEDs are now displayed.
38
delay(8);
// Wait 8 milliseconds until the next frame.
39
}
NUM_LEDS
#define NUM_LEDS
Definition
Animartrix.ino:79
leds
fl::CRGB leds[NUM_LEDS]
Definition
Animartrix.ino:93
brightness
fl::UISlider brightness("Brightness", BRIGHTNESS, 0, 255)
setup
void setup()
Definition
Apa102.ino:14
STRIP_DATA_PIN
#define STRIP_DATA_PIN
Definition
Apa102.ino:9
STRIP_CLOCK_PIN
#define STRIP_CLOCK_PIN
Definition
Apa102.ino:10
wrap_8bit
uint8_t wrap_8bit(int i)
Definition
Apa102.ino:20
loop
void loop()
Definition
Apa102.ino:29
FastLED
FL_DISABLE_WARNING_PUSH FL_DISABLE_WARNING_GLOBAL_CONSTRUCTORS CFastLED FastLED
Global LED strip management instance.
Definition
FastLED.cpp.hpp:75
APA102
@ APA102
APA102 LED chipset.
Definition
FastLED.h:262
arduino.h
RGB
constexpr EOrder RGB
Definition
eorder.h:17
CRGB
fl::CRGB CRGB
Definition
crgb.h:25
lib8tion.h
Fast, efficient 8-bit math functions specifically designed for high-performance LED programming.
examples
Apa102
Apa102.ino
Generated on Tue Jun 16 2026 00:06:58 for FastLED by
1.13.2