“两个Microduino BT互相通信”的版本间的差异

来自Microduino Wikipedia
跳转至: 导航搜索
 
第41行: 第41行:
 
[[File:Microduino-BLE-send-3.jpg|center]]
 
[[File:Microduino-BLE-send-3.jpg|center]]
 
|}
 
|}
 +
 +
'''[[Microduino-Module BLE/zh | 返回BLE模块页面]]'''

2018年6月13日 (三) 09:32的最新版本

  • 步骤二:

默认串口为软串口(D4,D5),这里介绍默认串口的连接方法,如果更改跳线你需要对应更改串口程序。注意软串口波特率不能高于38400.

  • 使用串口1(D2,D3):
    • 如果使用Core调试:请将程序的“SoftwareSerial mySerial(4, 5);”改成“SoftwareSerial mySerial(2, 3);”
    • 如果使用Core+调试:请将程序的“mySerial”改成“Serial1”,D2,D3对应的是Core+的串口1.
#include <SoftwareSerial.h>
SoftwareSerial mySerial(4, 5); // RX, TX

void setup()  
{
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  // set the data rate for the SoftwareSerial port
  mySerial.begin(9600);
}

void loop() // run over and over
{
  if(Serial.available())  
  {
    mySerial.write(Serial.read());
  }
  if(mySerial.available())  
  {
    Serial.write(mySerial.read());
  }
}

将程序下载到核心板,可以通过串口输入数据相互发送数据。

注意,蓝牙连接后,AT命令不起作用了,只能当数据发送出去。

返回BLE模块页面