“MCookie-BLE”的版本间的差异
502748957@qq.com(讨论 | 贡献) (→开发) |
502748957@qq.com(讨论 | 贡献) (→蓝牙通信程序(通用)) |
||
第54行: | 第54行: | ||
SoftwareSerial mySerial(4, 5); //根据实际模块上的跳线,选择对应端口 | SoftwareSerial mySerial(4, 5); //根据实际模块上的跳线,选择对应端口 | ||
− | #define my_Serial mySerial | + | #define my_Serial mySerial //声明软串口 |
void setup() | void setup() | ||
第72行: | 第72行: | ||
if (my_Serial.available() > 0) { | if (my_Serial.available() > 0) { | ||
− | currentInfo = my_Serial.readStringUntil('\n'); | + | currentInfo = my_Serial.readStringUntil('\n'); //接收手机发送的数据 |
− | Serial.println(currentInfo); | + | Serial.println(currentInfo); //手机发送过来的数据串口返回 |
} | } | ||
if (Serial.available() > 0) { | if (Serial.available() > 0) { | ||
− | item = Serial.readString(); | + | item = Serial.readString(); //接收PC端串口数据 |
− | my_Serial.println(item); | + | my_Serial.println(item); //串口数据发给手机 |
Serial.println(item); | Serial.println(item); | ||
第94行: | 第94行: | ||
[[file:BluetoothSerial.png|400px|thumb|center|LightBlue]] | [[file:BluetoothSerial.png|400px|thumb|center|LightBlue]] | ||
*结合图中示例,mCookie发送bb至手机,手机发送aa至mCookie | *结合图中示例,mCookie发送bb至手机,手机发送aa至mCookie | ||
+ | |||
===与IOS设备通信=== | ===与IOS设备通信=== | ||
*'''[[【使用LightBlue通信】]]''' | *'''[[【使用LightBlue通信】]]''' |
2018年11月22日 (四) 10:16的版本
Language | English |
---|
mCookie-BLE模块是蓝牙低能耗 (BLE) 的串口传输模块。可与其他蓝牙设备进行连接通讯。如手机,ipad借助相关APP可以和BT模块通信。 特色
规格
文档支持AT指令配置/控制, 具体AT指令表见此文档附录:[CC2541文档] 注意:
均会返回"ERROR",无法使用 开发编程手册:Protocol_Reference 蓝牙通信程序(通用)
#include <SoftwareSerial.h>
String item;
String currentInfo="";
SoftwareSerial mySerial(4, 5); //根据实际模块上的跳线,选择对应端口
#define my_Serial mySerial //声明软串口
void setup()
{
item = "";
my_Serial.begin(9600);
Serial.begin(9600);
}
void loop()
{
if (my_Serial.available() > 0) {
currentInfo = my_Serial.readStringUntil('\n'); //接收手机发送的数据
Serial.println(currentInfo); //手机发送过来的数据串口返回
}
if (Serial.available() > 0) {
item = Serial.readString(); //接收PC端串口数据
my_Serial.println(item); //串口数据发给手机
Serial.println(item);
}
}
使用lightblue连接蓝牙模块(名称为Microduino或mCookie-xxxxx) 连接后选择"read write without response Notify.
与IOS设备通信与MAC设备通信扩展应用蓝牙彩灯 问题解答
图库 |