【发布时间】:2018-10-14 22:44:56
【问题描述】:
我目前正在创建一个应用程序,我的 Android 手机会不断地向我的 Arduino 发送一个 Color-Integer。之后,单个 RGB 通道被解析并发送到 Neopixel。我得到了可怕的闪烁效果。因此,我得到了一些“?”在我的串行监视器中。如果没有连接 Neopixel,一切似乎都可以正常工作(关于颜色的接收和解析)。 有什么办法可以解决蓝牙新像素问题吗?
我在 Arduino-Site 上的代码如下:
void loop() {
if (bluetooth.available()){
current = bluetooth.read();
if(current == endChar) {
if(msg[0] = 'C') { // The first Character is the "key" to be received on Arduino
colorChange(msg);
} else if(msg[0] == 'S') {
fadeMode = true;
}
msg = "";
} else {
msg+=current;
}
}
}
void colorChange(String msg) {
//fadeMode = false;
msg.remove(0,1);
currentColor = atol(msg.c_str());
red = (currentColor >> 16) & 0xFF;
green = (currentColor >> 8) & 0xFF;
blue = currentColor & 0xFF;
for(int i = 0; i < NUMPIXELS; i++) {
pixels.setPixelColor(i, pixels.Color(red, green, blue));
}
pixels.show();
}
【问题讨论】:
-
我投票结束这个问题,因为它看起来像一个硬件问题,而不是编程问题。
标签: bluetooth arduino neopixel