Arduino 控制 ledstrip 与新像素卡住
Arduino controlling ledstrip with neopixel stuck
我尝试用我的 pi 2812b LED 灯条控制 rgb ws3b LED 灯条。这工作正常。现在我想用我的Arduino Nano来做这件事。控件本身有效。如果我将一些代码放入循环函数中,一切正常。但是如果我想通过函数调用代码,比如void colorWipe(({ change color },我在循环中调用colorWipe((,它不再改变颜色。为什么???
这是代码:
#include <Adafruit_NeoPixel.h>
#define shortStrip 2
#define longStrip 3
#define led_count_short 23
#define led_count_long 277
Adafruit_NeoPixel strip_short = Adafruit_NeoPixel(led_count_short, shortStrip, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel strip_long = Adafruit_NeoPixel(led_count_long, longStrip, NEO_GRB + NEO_KHZ800);
void setup(){
Serial.begin(9600);
strip_short.begin();
strip_short.setBrightness(50);
strip_short.show();
Serial.println("Short strip is running!");
delay(50);
strip_long.begin();
strip_long.setBrightness(50);
strip_long.show();
Serial.println("Long strip is running!");
delay(50);
}
void loop(){
colorWipe(10, strip_long, led_count_long, 255, 255, 255);
Serial.println("Finished Long");
delay(1000);
colorWipe(10, strip_long, led_count_long, 255, 0, 0);
Serial.println("This too Long");
delay(1000);
}
void colorWipe(uint8_t wait, Adafruit_NeoPixel strip, int led_count, int r, int g, int b){
Serial.print("1");
for(int i = 0; i < led_count; i++){
strip.setPixelColor(i, strip.Color(r,g,b));
strip.show();
delay(wait);
}
Serial.print("2");
return;
}
是的,我确实有 2 个 LED 灯条,但循环中只调用了 1 个。我的串行显示器打印一切正常,但颜色不会改变。我尝试了多种颜色。第一个 colorWipe(( 有效,之后的所有颜色擦除都不起作用。
请帮助
谢谢
你试过使用引用吗?将colorWipe
更改为
void colorWipe(uint8_t wait, Adafruit_NeoPixel & strip, int led_count, int r, int g, int b)
我的猜测是,当您复制strip
对象时,不再可能访问setPixelColor
和show
。应使用在代码开头声明的对象,这可以使用引用来完成。
相关文章:
- 如何在不产生任何垃圾的情况下获得C中的像素
- 在C++中使用GDAL可以将图像的像素坐标转换为lat,long吗
- 如何在24位SDL_Surface上设置像素的颜色
- 如何从SDL_Surface获取特定像素的颜色
- 如何将CMSampleBufferRef/CIImage/UIImage转换为像素,例如uint8_t[]
- 在C++中查找像素 RGB 数据的最快方法是什么?
- 是否可以从 OpenGL 缓冲区获取原始大小的像素?
- 选择基于另一个垫子的非零像素的cv::Mat的一部分?
- 如何使用 sdl2 快速绘制像素网格?
- 如何在C++中进行像素操作? - Linux
- 他们如何将红外锁定像素转换为镜头前方 1m 的正常平面上的位置
- 访问随机图像像素的快速方法,最多一次
- OpenCV 像素访问点与 at() - 不同的值
- 如何使用 freetype2 访问单色位图中的像素状态
- 尝试渲染像素坐标时,简单线条渲染失败
- 计算另一个图像像素满足条件的像素值的平均值
- 如何返回定义良好的内存部分?例如来自图像数据的像素的颜色值
- Arduino 控制 ledstrip 与新像素卡住
- 如何在windows控制台中为特定像素着色
- 控制投影仪单个像素的