【问题标题】:My HC-05 Bluetooth module is not receiving correct data我的 HC-05 蓝牙模块没有接收到正确的数据
【发布时间】:2017-05-29 07:17:25
【问题描述】:

我正在尝试使用 HC-05 构建 LED 闪光灯,但遇到了错误。

这是 Arduino 代码:

int data = 0;            //Variable for storing received data
void setup()
{
    Serial.begin(9600);   //Sets the baud for serial data transmission                               
    pinMode(13, OUTPUT);  //Sets digital pin 13 as output pin
}
void loop()
{
   if(Serial.available())      // Send data only when you receive data:
   {
      data = Serial.read();        //Read the incoming data & store into data
      Serial.print(data);          //Print Value inside data in Serial monitor
      Serial.print("\n");        
      if(data == 1)              // Checks whether value of data is equal to 1
         digitalWrite(13, HIGH);   //If value is 1 then LED turns ON
      else if(data == 0)         //  Checks whether value of data is equal to 0
         digitalWrite(13, LOW);    //If value is 0 then LED turns OFF
   }
}

无论我按下或关闭哪个按钮,int数据的值都将保持不变(255)。

我也使用了很多应用,所以我认为这不是应用问题。

【问题讨论】:

  • 与HC-05的关系如何?

标签: bluetooth arduino arduino-ide


【解决方案1】:

我找到了这个问题的答案。

只需更改波特率并观察输出。我的模块在 38400 上运行良好。

希望对你有所帮助。

【讨论】:

    猜你喜欢
    • 2022-01-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-22
    • 2018-03-10
    • 1970-01-01
    相关资源
    最近更新 更多