成果展示
1、整体设计框架
2、电路设计
3、程序流程设计
主程序:
void main()
{
uint sy_count1 = 0;
uint sy_count2 = 0;
uint yuyin = 0;
bit flag = 0;
char xdata SEND_BUF[]="心率:000,温度:00.0C\r\n";
time_init();//定时器初始化
lcd_init();//1602初始化
lcd_write_str(0, 0, " CLOSE 00.0C");
lcd_write_str(0, 1, "MS: ZIDONG 000");
uart_init(9600);
while(1)
{
keyscan();
if(setn == 0)
{
if(Mode == 0)//在自动模式下
{
if(Voice == 0)//检测到有声音
{
if(sy_count1++ > 10)//检测哭声是否延续
{
DJ_TIME = 60;//电机开启时间1分钟
openFlag = 1;//电机开启
sy_count1 = 0;
if(ShiDu==0)Line_1A(1);//播放歌曲
}
}
else
{
if(sy_count2++ > 200)
{
sy_count2 = 0;
sy_count1 = 0;
}
}
}
if(ShiDu==1)//检测到尿不湿湿了
{
LED = 0;
if(flag == 0)//只播放一次
{
flag = 1;
Line_1A(0);//播报
yuyin = 0;
}
if(flag==1)
{
if(yuyin++ > 400)
{
yuyin = 0;
Line_1A(0);//播报
}
}
}
else
{
LED = 1;flag = 0;
}
if(openFlag==1)//电机开启
{
lcd_write_str(0, 0, " OPEN");
motoRotate();
}else
{
lcd_write_str(0, 0, " CLOSE");
MotorStop();//点击关闭
}
rountine();
//显示心率值体温值
lcd_write_char(13,1,heartrate/100+'0');
lcd_write_char(14,1,heartrate%100/10+'0');
lcd_write_char(15,1,heartrate%10+'0');
lcd_write_char(11,0,temperature/100+'0');
lcd_write_char(12,0,temperature%100/10+'0');
lcd_write_char(14,0,temperature%10+'0');
SEND_BUF[5]=heartrate/100+'0';
SEND_BUF[6]=heartrate%100/10+'0';
SEND_BUF[7]=heartrate%10+'0';
SEND_BUF[14]=temperature/100+'0';
SEND_BUF[15]=temperature%100/10+'0';
SEND_BUF[17]=temperature%10+'0';
if(((heartrate<=heartrateMin||heartrate>=heartrateMax)&&heartrate!=0)||(temperature>=temperatureMax))//心率或体温超过上下限
BEEP = 0;
else
BEEP = 1;
if(sendFlag==1)
{
sendFlag = 0;
uart_send(SEND_BUF,0xFF);//串口发送
}
}
delay_ms(1);
}
}
4、功能介绍
4.1元件组成
4.2婴儿哭闹
实现效果:
婴儿哭闹演示
设计思路:
程序详情:
void motoRotate()//电机处理
{
static uint djcount=0;
static bit flag = 0;
if(flag == 0)
{
djcount++;
if(djcount < 30)
{
MotorCW();//正转
}
else
{
if(djcount < 130)
{
MotorStop();//电机停止
}
else
{
flag = 1;
djcount = 130;
}
}
}
else
{
djcount--;
if(djcount > 100)
{
MotorCCW();//电机反转
}
else
{
if(djcount<=0){flag = 0;djcount=0;}
MotorStop();//电机停止
}
}
}
4.3尿床检测
实现效果:
尿床演示
设计思路:
程序详情:
if(ShiDu==1)//检测到尿不湿湿了
{
LED = 0;
if(flag == 0)//只播报一次
{
flag = 1;
Line_1A(0);//播报
yuyin = 0;
}
if(flag==1)
{
if(yuyin++ > 400)
{
yuyin = 0;
Line_1A(0);//播报
}
}
}
4.4体温和心率检测
实现效果:
心率检测演示
设计思路:
程序详情:
//显示心率和体温值
lcd_write_char(13,1,heartrate/100+'0');
lcd_write_char(14,1,heartrate%100/10+'0');
lcd_write_char(15,1,heartrate%10+'0');
lcd_write_char(11,0,temperature/100+'0');
lcd_write_char(12,0,temperature%100/10+'0');
lcd_write_char(14,0,temperature%10+'0');
SEND_BUF[5]=heartrate/100+'0';
SEND_BUF[6]=heartrate%100/10+'0';
SEND_BUF[7]=heartrate%10+'0';
SEND_BUF[14]=temperature/100+'0';
SEND_BUF[15]=temperature%100/10+'0';
SEND_BUF[17]=temperature%10+'0';
if(((heartrate<=heartrateMin||heartrate>=heartrateMax)&&heartrate!=0)||(temperature>=temperatureMax))//心率或体温超过上下限
BEEP = 0;
else
BEEP = 1;
if(sendFlag==1)
{
sendFlag = 0;
uart_send(SEND_BUF,0xFF);//串口发送
}
5.相关技术
元件清单:
模块 | 名称 |
---|---|
声音采集 | TELESKY 声音传感器模块 |
温度检测 | DS18B20 |
心率检测 | PulseSensor脉搏心率传感器 |
湿度检测 | CON4 |
蓝牙传输 | HC05 |
步进电机 | CON5 |
比较器 | LM393 |
单片机 | ST89C52 |
液晶 | LCD1602 |
开发环境:
用途 | 名称 |
---|---|
程序编写 | Keil uVision4 |
原理图设计 | Altium Designer |
电路仿真设计 | Proteus8.6 |