arduino - 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 颜色会改变,但它永远不会改变。
解决方案
推荐阅读
- c# - 接收 LINQ 查询时,DataGridView 的功能与 GridView 不同吗?
- google-tag-manager - 浏览量触发器未在 gtm.dom 或 gtm.load 上触发 | 谷歌标签管理器
- python - 在没有科学计数法的情况下将浮点数转换为字符串
- pandas - 如何将年、日、月转换为日期时间?
- html - 如何收集复选框名称并发送请求?
- django - 获取所有具有 M2M 关系的 Django 对象
- node.js - Vue2 timepicker:来自 API 的默认值
- powershell - 在 Powershell 中覆盖 zip 文件中的相同名称
- javascript - VueJS 忽略 InnerHTML
- ruby - 助手内部的 Sinatra 自定义异常处理不起作用