这是一条完全没有个性的个性签名.|

Yang-blackSun

园龄:2年4个月粉丝:0关注:3

2023-02-07 18:39阅读: 7评论: 0推荐: 0

esp蓝牙透传

#include <Arduino.h>
#include "BluetoothSerial.h"
BluetoothSerial bt1;
void setup()
{
Serial.begin(115200);
delay(5000);
bt1.begin("ESP32BLUE");
Serial.println("Waiting for Bluetooth connection........");
}
void loop()
{
if (Serial.available())
{
bt1.write(Serial.read());
}
if (bt1.available())
{
Serial.write(bt1.read());
}
delay(20);
}

示例2

#include "BluetoothSerial.h"
#if !defined(CONFIG_BT_ENABLED) || !defined(CONFIG_BLUEDROID_ENABLED)
#error Bluetooth is not enabled! Please run `make menuconfig` to and enable it
#endif
BluetoothSerial SerialBT;
void setup() {
Serial.begin(115200);
SerialBT.begin("ESP32test"); //Bluetooth device name
Serial.println("The device started, now you can pair it with bluetooth!");
}
void loop() {
if (Serial.available()) {
SerialBT.write(Serial.read());//将串口收到的数据,再通过蓝牙串口转发出去
Serial.println("由SerialBT打印");
}
if (SerialBT.available()) {//将蓝牙串口收到的数据,再通过串口把信息发回给电脑
Serial.write(SerialBT.read());
Serial.println("由Serial打印");
}
delay(20);
}

本文作者:ClingYang

本文链接:https://www.cnblogs.com/Yang-blackSun/p/18025358

版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。

版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。

本文作者:Yang-blackSun

本文链接:https://www.cnblogs.com/Yang-blackSun/p/18025358

posted @   Yang-blackSun  阅读(7)  评论(0编辑  收藏  举报  
点击右上角即可分享
微信分享提示
💬
评论
📌
收藏
💗
关注
👍
推荐
🚀
回顶
收起
  1. 1 404 not found REOL
404 not found - REOL
00:00 / 00:00
An audio error has occurred.
评论
收藏
关注
推荐
深色
回顶
收起