Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/arduino/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/backbone.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Bluetooth 使用蓝牙控制Arduino上的Neopixel会导致闪烁_Bluetooth_Arduino_Neopixel - Fatal编程技术网

Bluetooth 使用蓝牙控制Arduino上的Neopixel会导致闪烁

Bluetooth 使用蓝牙控制Arduino上的Neopixel会导致闪烁,bluetooth,arduino,neopixel,Bluetooth,Arduino,Neopixel,我目前正在创建一个应用程序,我的Android手机会不断向我的Arduino发送一个颜色整数。然后,解析单个RGB通道并将其发送到Neopix。我有一种可怕的闪烁效果。因此,我的串行监视器中有一些“?”。如果没有Neopixel连接,一切看起来都很好(关于颜色的接收和解析)。 有没有办法解决蓝牙Neopixel的问题 我在Arduino网站上的代码如下: void loop() { if (bluetooth.available()){ current = bluetooth.

我目前正在创建一个应用程序,我的Android手机会不断向我的Arduino发送一个颜色整数。然后,解析单个RGB通道并将其发送到Neopix。我有一种可怕的闪烁效果。因此,我的串行监视器中有一些“?”。如果没有Neopixel连接,一切看起来都很好(关于颜色的接收和解析)。 有没有办法解决蓝牙Neopixel的问题

我在Arduino网站上的代码如下:

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();
}
void循环(){
if(bluetooth.available()){
当前=bluetooth.read();
如果(当前==endChar){
如果(msg[0]='C'){//第一个字符是在Arduino上接收的“密钥”
变色(味精);
}else if(消息[0]=“S”){
fadeMode=true;
}
msg=“”;
}否则{
msg+=电流;
}
}
}
void colorChange(字符串msg){
//fadeMode=false;
去除味精(0,1);
currentColor=atol(msg.c_str());
红色=(currentColor>>16)和0xFF;
绿色=(当前颜色>>8)&0xFF;
蓝色=当前颜色&0xFF;
对于(int i=0;i
上传已知有效的测试代码时,Neopix是否正常工作? 如果是这样,我会尝试更改将蓝牙颜色值传递给neopixel的部分,甚至删除它并逐部分添加,以查看问题的根源。
我想你已经试着在串行监视器上查看arduino接收到的值,以验证闪烁实际上不是来自android端。

我投票结束这个问题,因为它看起来像是硬件问题,而不是编程问题。