⭐ 简介
WS2812是一种可编程的LED灯,具有RGB显示效果,可显示的颜色数量为2^24。⭐ 如何使用
准备 & 硬件连接
准备 & 硬件连接
例程代码
例程代码
- 需要将Artikit-RGB模组的拨码开关1,调整至ON。
- 打开Arduino的程序编译环境,上传以下代码:
ws2812.ino
运行结果
运行结果
可以看到彩灯交替闪烁。
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
准备 & 硬件连接
例程代码
#include <FastLED.h>
#define DATA_PIN 7
#define NUM_LEDS 4
CRGB leds[NUM_LEDS];
uint8_t max_bright = 128;
void setup()
{
FastLED.addLeds<WS2812, DATA_PIN, GRB>(leds, NUM_LEDS);
FastLED.setBrightness(max_bright);
}
void loop() {
for (int i = 0; i < NUM_LEDS; i++) {
leds[i] = CRGB::Red;
FastLED.show();
delay(500);
leds[i] = CRGB::Black;
}
}
运行结果