首页 > 解决方案 > Arduino串行引脚未接收数据

问题描述

我正在尝试运行 Geeetech 语音识别模块来识别我的命令并用它们改变 Neopixels 的颜色。问题是,我的 Arduino 从未接收到语音识别模块的输出。将它连接到我的计算机并使用 AccessPort 进行通信时,一切正常。该模块正确连接到 Rx 和 Tx 引脚,它甚至可以接收来自 Arduino Uno 的启动数据。

我已经尝试通过串行监视器发送命令,Arduino Rx LED 很快闪烁,当我的语音识别模块应该发送数据时它从不闪烁。我什至尝试通过单独的电源为其供电,但它没有改变任何东西。我在上传时断开 Rx 引脚,然后连接引脚,然后使用 Arduino 的重置按钮。

#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
  #include <avr/power.h>
#endif

#define PIN 5
Adafruit_NeoPixel strip = Adafruit_NeoPixel(1, PIN, NEO_GRB + NEO_KHZ800);
byte com = 0;

void setup()
{
Serial.begin(9600);
  strip.begin();
  strip.show();
  delay(2000);
  Serial.write(0xAA);
  Serial.write(0x37);
  delay(1000);
  Serial.write(0xAA);
  Serial.write(0x21);
}

void loop() // run over and over again
{ 
  if(Serial.available() > 0)
  {
    com = lowByte(Serial.read());
    switch(com)
    {
      case 0x11:
        strip.setPixelColor(0, strip.Color(255,255,255));
         break;
      case 0x12:
         strip.setPixelColor(0, strip.Color(255,0, 0));
         break;
      case 0x13:
          strip.setPixelColor(0, strip.Color(0,255, 0));
          break;
      case 0x14:
          strip.setPixelColor(0, strip.Color(0, 0, 255));
          break;
      case 0x15:
          strip.setPixelColor(0, strip.Color(0,0,0));
          break;
    }
  }
  delay(250);
}

我希望 LED 颜色会改变,但它永远不会改变。

标签: arduinovoice-recognitionneopixel

解决方案


推荐阅读