【问题标题】:Controlling Neopixel on Arduino using Bluetooth results in Flickering使用蓝牙控制 Arduino 上的 Neopixel 会导致闪烁
【发布时间】: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


【解决方案1】:

当您上传已知有效的测试代码时,您的 neopixel 是否正常工作? 如果是这样,我会尝试更改将蓝牙颜色值传递给neopixel的部分,甚至将其删除并逐部分添加以查看问题出在哪里。 我想您已经尝试在串行监视器上查看 arduino 接收到的值,以验证闪烁实际上不是来自 android 端。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-11-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多