释放双眼,带上耳机,听听看~!
一.介绍
今天我们将制作一个很酷的多彩项目,我们将使用ESP32微控制器通过蓝牙控制rgb LED。简单来说,我们将通过手机控制RGB-LED。
ESP内置有低功耗蓝牙,它与我们在蓝牙音频等产品中可能会发现的传统蓝牙略有不同。BLE“服务器”(如ESP32读取传感器数据)可以定期“通知”客户端(如智能手机),而不是不断地传输数据,而是向他们发送一些数据。因此,BLE更适用于不需要大量数据的低功耗物联网应用。
前面的我们已经介绍了RGB-LED灯的如何使用了,我这里就不多说了。在这里我就重点说一下,ESP32内置蓝牙的使用。
二.元器件清单
ESP32开发板
一个RGB-LED
面包板
导线若干
三.电路图
四.代码设计
关于这里的android手机端的软件可以从这里下载
关于arduino的代码接下来,我就进行详细地介绍,根据我自己的研究发现,使用ESP32的arduino示例程序BluetoothSerial:
//This example code is in the Public Domain (or CC0 licensed, at your option.)
//By Evandro Copercini - 2018
//
//This example creates a bridge between Serial and Classical Bluetooth (SPP)
//and also demonstrate that SerialBT have the same functionalities of a normal Serial
#include "BluetoothSerial.h"
#if !defined(CONFIG_BT_ENABLED) || !defined(CONFIG_BLUEDROID_ENABLED)
#error Bluetooth is not enabled! Please run `make menuco