蓝牙控制esp32单片机(三)

目录

一.前期材料准备

二.具体操作

1.spp蓝牙串口app下载

2.具体操作流程

esp32单片机图例 

 测试代码

3.生成副本进行备份

三.总结

1.操作过程中存在的问题


一.前期材料准备

1.安装vs-code、准备好esp32 开发环境

2.一个电路板。一台电脑

3.一台已下载好spp蓝牙串口的手机

二.具体操作

1.spp蓝牙串口app下载

可在应用商店搜索下载,参照如下图

 下载完成之后就可以进行链接啦

1.先打开APP,进行注册

2.注册完成之后将进行程序写入

2.具体操作流程

1.使用VS-code打开Espressif中提供的文件,此处本人使用了指导老师提供的代码文件

 先使用vs-code对该段程序进行编译、并写入单片机

2.打开蓝牙,使用spp蓝牙串口搜索,找到自己编写的蓝牙名称,JFBike,点击连接

 连接成功之后如下图所示,与此同时,单片机蜂鸣器响

 3.同时可发送数据,发送成功,蜂鸣器响

esp32单片机图例 

 测试代码

 以下代码段由指导老师提供,有些许改动,仅供参考。

/* Hello World Example

   This example code is in the Public Domain (or CC0 licensed, at your option.)

   Unless required by applicable law or agreed to in writing, this
   software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
   CONDITIONS OF ANY KIND, either express or implied.
*/
/* GPIO Example

   This example code is in the Public Domain (or CC0 licensed, at your option.)

   Unless required by applicable law or agreed to in writing, this
   software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
   CONDITIONS OF ANY KIND, either express or implied.
*/

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/queue.h"
#include "driver/gpio.h"

#include "lvgl_init.h"


#include "soc/rtc.h"
#include "driver/mcpwm.h"
#include "soc/mcpwm_periph.h"


#include "time.h"
#include "sys/time.h"
#include "sys/unistd.h"

#include "driver/adc.h"
#include "esp_adc_cal.h"

#include "esp_log.h"

#define _SUPPORT_BT_ 1




typedef unsigned char  u8;
typedef unsigned short u16;
typedef unsigned int   u32;

uint8_t DebugOn = 1;
#define DEBUG_CODE    if(DebugOn)

#define GPIO_OUTPUT_IO_BEEP         19


#define START_BEEP      {mcpwm_start(MCPWM_UNIT_0, MCPWM_TIMER_0);}
#define STOP_BEEP       {mcpwm_stop(MCPWM_UNIT_0, MCPWM_TIMER_0);}

// #define POWER_ON        {mcpwm_start(MCPWM_UNIT_0, MCPWM_TIMER_2);}
// #define POWER_OFF       {mcpwm_stop(M
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

久长愿长久

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值