一:功能介绍:
1、系统组成:采用stm32f103c8t6核心板+DHT11温湿度+DS1302时间模块+LCD1602显示屏+蜂鸣器+按键
2、通过DHT11传感器采集温湿度,显示到LCD1602上面;
3、通过DS1302模块读取时间,显示到LCD1602上面;
4、通过按键统计人数多少,显示到LCD1602上面;
5、当人数超过10人(阈值程序可调),蜂鸣器进行报警提醒;
二:实物演示视频
245-基于stm32单片机人流量统计按键计数系统
三:程序代码展示(采用C语言编写,使用keil5编译,代码有中文注释,新手容易看懂)
void Display(void)
{
char xxx=0,yyy=0;
//T1 温度
WrByte1602(0,0,'T'); //.
WrByte1602(0,1,'='); //.
WrByte1602(0,2,AsciiCode[wendu%100/10]);
WrByte1602(0,3,AsciiCode[wendu%10]);
WrByte1602(0,4,' ');
//T2 湿度
WrByte1602(0,8,'H'); //.
WrByte1602(0,9,'='); //.
WrByte1602(0,10,AsciiCode[shidu%100/10]);
WrByte1602(0,11,AsciiCode[shidu%10]);
WrByte1602(0,12,' ');
xxx=0;yyy=1;
WrByte1602(yyy,xxx++,AsciiCode[shi%100/10]);//时间显示
WrByte1602(yyy,xxx++,AsciiCode[shi%10]);
WrByte1602(yyy,xxx++,':');
WrByte1602(yyy,xxx++,AsciiCode[fen%100/10]);
WrByte1602(yyy,xxx++,AsciiCode[fen%10]);
WrByte1602(yyy,xxx++,':');
WrByte1602(yyy,xxx++,AsciiCode[miao%100/10]);
WrByte1602(yyy,xxx++,AsciiCode[miao%10]);
WrByte1602(yyy,xxx++,' '); //人数显示
WrByte1602(yyy,xxx++,'R');
WrByte1602(yyy,xxx++,'E');
WrByte1602(yyy,xxx++,'N');
WrByte1602(yyy,xxx++,' ');
WrByte1602(yyy,xxx++,AsciiCode[ren/100]);
WrByte1602(yyy,xxx++,AsciiCode[ren%100/10]);
WrByte1602(yyy,xxx++,AsciiCode[ren%10]);
}
int main(void)
{
//时钟配置
SystemInit();
SystemCoreClockUpdate();
//引脚配置
GPIO_Configuration();
//LCD1602初始化
Init1602();
NVICConfig();
//RCC时钟开启
RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM1, ENABLE);
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE);
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE);
DS1302_Init();
delay_ms(300);
//DS1302_Write_Time();
DS1302_Get_Time(time_data); //读取时间
shi=time_data[9]*10+time_data[10];
fen=time_data[11]*10+time_data[12];
miao=time_data[13]*10+time_data[14];
xiaoshi=shi;
fenzhong = fen+1;
while (1)
{
delay_ms(10);
//读取温湿度
DHT11_receive(&shidu,&wendu);
DS1302_Get_Time(time_data); //读取时间
shi=time_data[9]*10+time_data[10];
fen=time_data[11]*10+time_data[12];
miao=time_data[13]*10+time_data[14];
//显示全部参数
Display();
//按键扫描
anjiansaomiao();
if(ren>10) PBout(6)=0;//大于设置值 蜂鸣器报警
else PBout(6)=1;
}
}
四:原理图文件展示(采用AD(Altium Designer)打开)
五:实物图展示:
六: 资料清单展示: