【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
实验二百一十六:WS2812B幻彩LED灯带 5V全彩灯条5050灯珠内置IC炫彩单点单控软灯条模块
实验程序五:具有移动效果的渐变调色板
- /*
- 【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
- 实验二百一十六:WS2812B幻彩LED灯带 5V全彩灯条5050灯珠内置IC炫彩单点单控软灯条模块
- 实验程序五:具有移动效果的渐变调色板
- */
-
- #include <FastLED.h>
-
- #define DATA_PIN 6
- #define NUM_LEDS 24
- #define BRIGHTNESS 100
- #define LED_TYPE WS2812B
- #define COLOR_ORDER GRB
-
- CRGB leds[NUM_LEDS];
-
- uint8_t paletteIndex = 0;
-
- DEFINE_GRADIENT_PALETTE( temperature_gp ) {
- 0, 1, 27,105,
- 14, 1, 27,105,
- 14, 1, 40,127,
- 28, 1, 40,127,
- 28, 1, 70,168,
- 42, 1, 70,168,
- 42, 1, 92,197,
- 56, 1, 92,197,
- 56, 1,119,221,
- 70, 1,119,221,
- 70, 3,130,151,
- 84, 3,130,151,
- 84, 23,156,149,
- 99, 23,156,149,
- 99, 67,182,112,
- 113, 67,182,112,
- 113, 121,201, 52,
- 127, 121,201, 52,
- 127, 142,203, 11,
- 141, 142,203, 11,
- 141, 224,223, 1,
- 155, 224,223, 1,
- 155, 252,187, 2,
- 170, 252,187, 2,
- 170, 247,147, 1,
- 184, 247,147, 1,
- 184, 237, 87, 1,
- 198, 237, 87, 1,
- 198, 229, 43, 1,
- 212, 229, 43, 1,
- 212, 220, 15, 1,
- 226, 220, 15, 1,
- 226, 171, 2, 2,
- 240, 171, 2, 2,
- 240, 80, 3, 3,
- 255, 80, 3, 3};
-
- CRGBPalette16 myPalette = temperature_gp;
-
- void setup() {
- FastLED.addLeds<LED_TYPE, DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS);
- FastLED.setBrightness(BRIGHTNESS);
- }
-
- void loop() {
- fill_palette(leds, NUM_LEDS, paletteIndex, 255 / NUM_LEDS, myPalette, BRIGHTNESS, LINEARBLEND);
- EVERY_N_MILLISECONDS(10) {
- paletteIndex++;
- }
- FastLED.show();
- }
复制代码
|