通过湿度范围来区分是干垃圾还是湿垃圾,范围可以手动按键设定当实际湿度HH,那么判定为湿垃圾,此时电机转动打开是垃圾桶。
如果红外传感器(开关模拟)检测到人体靠近是,蜂蜜报警提示。
#include
#include
#include
#include
#define uchar unsigned char
#define uint unsigned int
//定义四个输出端口
sbit Led_jiashi=P3^4; //干垃圾
sbit Led_qushi=P3^3; //湿垃圾
sbit Led_jiangwen=P3^1;
sbit Led_shengwen=P3^2;
//定义三个设置按键
sbit Key_SET = P2^0;
sbit Key_ADD = P2^1;
sbit Key_SUB = P2^2;
sbit Key_OK = P2^3;
sbit Key_HONG = P2^4;
//定义24C02数据口
sbit SCL = P1^0;
sbit SDA = P1^1;
//定义DHT11数据口
sbit DATA = P1^7;
sbit buzz=P3^5;
//定义LCD1602端口
sbit E=P1^3; //1602使能引脚
//sbit RW=P2^6; //1602读写引脚
sbit RS=P1^2; //1602数据/命令选择引脚
//定义全局变量
uchar U8FLAG,U8temp,U8comdata,U8RH_data_H_temp,U8RH_data_L_temp,U8T_data_H_temp,U8T_data_L_temp,U8checkdata_temp;
uchar U8RH_data_H,U8RH_data_L,U8T_data_H,U8T_data_L,U8checkdata;