0

我正在尝试将我的 MSP432 连接到我的 HC-05 蓝牙模块,但是当我使用蓝牙终端连接到模块时,我没有收到任何反馈。我也附上了我的代码。RX 引脚是 P3.2 和 TX P3.3 吗?

void setup() {
  Serial.begin(9600); /* Define baud rate for serial communication */
  pinMode(12, OUTPUT);
}

void loop() {
  
    if (Serial.available())  /* If data is available on serial port */
    {
      char data_received; 
      data_received = Serial.read();  /* Data received from bluetooth */
      if (data_received == '1')
      {
        digitalWrite(12, HIGH);
        Serial.write("LED turned ON");        
      }
      else if (data_received == '2')
      {
        digitalWrite(12, LOW);
        Serial.write("LED turned OFF");
      }
      else
      {
        Serial.write("Select either 1 or 2");
      }
    }
}
4

0 回答 0