功能描述
STM32单片机+循迹+避障+蓝牙控制+温度采集+声光报警+按键调节+OLED显示+风扇吸尘
1. STM32单片机为控制核心
2. 通过ds18b20传感器测量环境温度
3. OLED显示屏显示模式及测量的信息;
4. 通过红外循迹传感器可以实现小车沿黑线进行循迹清扫
5. 通过两路红外光电传感器进行避障,可以实现全屋随意清扫
6. 蓝牙通信,可以通过手机公共APP(蓝牙串口调试助手)实现控制小车的前进方向,遥控清扫;
7. 可以切换清扫模式(循迹清扫/全屋避障清扫/蓝牙手动遥控清扫)
实物可做,其他功能实物也可以!
实物图
电路图
PCB
源代码
#include <reg52.h>
#include <intrins.h>
#include <stdio.h>//printf串口输出头文件
#define uchar unsigned char
#define ushort unsigned int
#define uint unsigned long
#include "lcd1602.h"
#include "uart_trx.h"
#include "eeprom52.h"
#define RATIO 800 //系数,建议选择800-1000
sbit key1 = P1^0;//加键
sbit key2 = P1^1;//减键
sbit beep = P2^0;//蜂鸣器
sbit Fan = P1^3;//风扇
unsigned char pmBuf[7] = 0;//数据接收数组
uint PM25_Value = 0; //PM = ((pmBuf[1]<<8)+pmBuf[2])/1024*8*ratio
uint PM25_ValueMax = 200; //上限初始值
void EEPROM_WRITE()//EEPROM写入
{
SectorErase(0x2000);//擦除扇区
byte_write(0x2001, (PM25_ValueMax>>8)&0xFF);//存储高8位
byte_write(0x2002, (PM25_ValueMax>>0)&0xFF);//存储低8位
byte_wri