我刚买了一个带有CC2541芯片的蓝牙HM-10模块。我用 Arduino Uno 为它供电。我用手机(三星 j3,2016)扫描了蓝牙设备,发现模块名为 BT05。我将设备配对,但无法将蓝牙模块与任何应用程序连接。我尝试将它与AMR Voice/BT Voice Control 应用程序和LED 控制器连接。我用于通过应用程序控制 LED 的代码来自这里:create.arduino.cc/projecthub/user206876468/arduino-bluetooth-basic-tutorial-d8b737
我也把代码放在这里:
char 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() > 0) // 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
}
}