要做一个简单的装置,需要用到两个蓝牙模块分别与两块Arduino连接,一个作为发送,一个作为接收。
关于HC-05与Arduino的连接与调试如下:
HC-05引脚:
STATE:蓝牙连接状态指示,连接成功此引脚为高电平,没有连接则为低电平
RX:接收端
TX:发送端
GND:接地端
+5V:5V电源输入端
EN:使能端,需要进入AT模式时接3.3V。其实不接也没有关系
1.接线与进入AT模式设置:
接线:
- RX —>TX
- TX —>RX
- GND —>GND
- +5V —>5V
另外两个引脚可以不接
在arduino下载以下程序,为了不与arduino自带串口冲突,选用软件模拟串口,我选用6,7引脚
#include <SoftwareSerial.h>
SoftwareSerial BTserial(6, 7); // RX | TX
// Connect the HC-05 TX to Arduino pin 6 RX.
// Connect the HC-05 RX to Arduino pin 7 TX through a voltage divider.
char c = ' ';
void setup()
{
// start th serial communication with the host computer
Serial.begin(9600);
Serial.println("Arduino with HC-05 is ready");
// start communication