arduino - 在 arduino 上运行 WS2812B 条带
问题描述
我购买了一条 5 米长的 WS2812B LED 灯带,与运动检测器(WS2812B 5 Pins RGBW RGBWW 4 IN 1 LED Strip Light Non-Waterproof DC5V)结合使用。
这些条连接到 5V 电源(USB 移动电源)和 arduino UNO 引脚 6 上的 GND/5V/信号。
需要注意的是,到目前为止我还没有切割 LED 灯条,所以所有 5 米都完好无损。
- 我尝试使用下面的代码使用 FASTLED 库让 LED 发出简单的颜色。蓝色/蓝色/蓝色组合导致 LED 0-2 上的蓝色/红色/绿色颜色 更改为红色/红色/红色产生黄色/蓝色/关闭 更改为绿色/绿色/绿色产生红色/浅绿色-关闭/关闭
- 我尝试从 RGB 转换为 RBG 配色方案无济于事
- 除了我已经为您提供的信息外,我没有太多关于 LED 灯条的信息
你能给我一些关于如何进行的想法吗?
#include "FastLED.h"
#define NUM_LEDS 5
#define DATA_PIN 6
// Define the array of leds
CRGB leds[NUM_LEDS];
void setup()
{
//FastLED.addLeds<WS2812B, DATA_PIN, RGB>(leds, NUM_LEDS);
FastLED.addLeds<WS2812, DATA_PIN, RGB>(leds, NUM_LEDS); // for GRB LEDs
}
void loop()
{
leds[0] = CRGB::Blue;
leds[1] = CRGB::Blue;
leds[2] = CRGB::Blue;
FastLED.show();
delay(500);
解决方案
这可能不是您正在寻找的确切答案,但我建议为您的 LED 使用 Adafruit_Neopixel.h 库。刚刚用那个库和你正在使用的确切的 LED 灯条做了一个 Projekt,到目前为止它工作得很好。
#include "Adafruit_NeoPixel.h"`
#define LED_PIN 6
#define LED_COUNT 60
Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);
int red = 100;
int green = 0;
int blue = 0;
void setup() {
strip.begin(); // INITIALIZE NeoPixel strip object (REQUIRED)
strip.show(); // Turn OFF all pixels ASAP}
}
void loop() {
for (i=0; i<LED_COUNT; i++){
strip.setPixelColor(i, strip.Color(Red, Green, Blue));
strip.show();
}
}
这应该使 60 个 LED 变为红色。如果你想查看的话,我的 GitHub 页面上也有一个 LED 项目。如果上面的代码仍然不起作用,我认为您的接线错误。我用电源为我的芯片和 LED 供电,也使用电源的接地。
推荐阅读
- python - 多次运行读取 csv 文件的 c++ 脚本
- php - 使用 foreach php 进行动态估值
- hibernate - 使用 JPA 标准省略不需要的 JOIN
- c# - “程序集加载”只是“读取元数据表”的另一个术语吗?
- maven - 在 azure-webapp-maven-plugin 中配置运行状况检查
- php - caldav php 客户端 - 获得空闲时间
- c# - 使用数据注释将十进制值截断至 2 点
- tensorflow - 保存 TensorFlow 神经网络 KFold 交叉验证模型
- git - 识别所有只有一个主分支的存储库
- mysql - 我可以在 MySQL 中动态/逻辑别名列吗?