(末尾附文件)
本系统由STM32单片机最小系统、LED指示灯、2档拨动开关、蜂鸣器报警、蓝牙模块组成。 1、手机APP和stm32设备上蓝牙模块进行连接。 2、三个拨动开关分别代表3个床位呼叫开关(1-3床位),开关拨上去,则相应的指示灯闪烁报警,同时蜂鸣器鸣叫报警。开关拨下,则蜂鸣器不鸣叫,LED灯也不闪烁。同时,系统将通过蓝牙模块实现病人和医护人员之间信息的传递。医护人员的手机可以实时接收床位的相关报警信息。
2档拨动开关
LED信号指示灯电路设计
STM32F103C8T6单片机核心板: USB供电接口,复位按键 开关按键 合理优秀的布局布线:
部分代码设计
#include "led.h" #include "delay.h" #include "sys.h" #include "timer.h" #include "key.h" #include "usart.h" #include <string.h> unsigned char delay20msFlag = 0; unsigned char BufTab[10]; //串口数据暂存 unsigned char Count; //串口数据计数 unsigned char UartBusy=0; //判断忙碌 unsigned char ReadFlag=0;//读取标志 unsigned char sendDataFlag=0; //发送数据标志 u8 rebackFalg= 0; //数据返回标志 u8 MesCount=0; //发送内容计数 unsigned char roomFlag0 = 0; //房间标志 unsigned char roomFlag1 = 0; unsigned char roomFlag2 = 0; unsigned char i ; int main(void) { delay_init(); //延时函数初始化 NVIC_Configuration();//设置NVIC中断分组2:2位抢占优先级,2位响应优先级 LED_Init(); //初始化与LED连接的硬件接? KEY_Init(); uart_init(4800);//初始化串口//**All notes can be deleted and modified**// TIM3_Int_Init(499,7199);//10Khz的计数频率,计数到500为50ms delay_ms(50); buzzer = 0 ;//关闭led及蜂鸣器 led0 = 1; led1 = 1; led2 = 1; while(1) { if(key0 == 0) //开关是否拨动 { roomFlag0 = 0; //该房间是否警报标志 } else { roomFlag0 = 1; //该房间是否警报标志 清空 } if(key1 == 0) //开关是否拨动 { roomFlag1 = 0; //该房间是否警报标志 } else { roomFlag1 = 1; //该房间是否警报标志 清空 } if(key2 == 0) //开关是否拨动 { roomFlag2 = 0; //该房间是否警报标志 } else { roomFlag2 = 1; //该房间是否警报标志 清空 } if(delay20msFlag ==1 )//定时更新显示情况 { delay20msFlag = 0; if(roomFlag2==0) {led2 = !led2;}//闪烁led灯 else {led2 = 1;} if(roomFlag1==0) {led1 = !led1;} //闪烁led灯 else {led1 = 1;} if(roomFlag0==0) {led0 = !led0;}//闪烁led灯 else {led0 = 1;} if((roomFlag0 == 0)||(roomFlag1 == 0)||(roomFlag2 == 0)) {buzzer = !buzzer;} //有任何异常报警 else {buzzer = 0 ;}//取消报警 Count++; if(Count>=5) { Count = 0; if(roomFlag2==0) {printf("1#Dangerous! ");} //蓝牙发送危险信息 else {printf("1#Normal! ");}//蓝牙发送正常信息 if(roomFlag1==0) {printf("2#Dangerous! ");} //蓝牙发送危险信息 else {printf("2#Normal! ");}//蓝牙发送正常信息 if(roomFlag0==0) {printf("3#Dangerous! ");}//蓝牙发送危险信息 else {printf("3#Normal! ");} //蓝牙发送正常信息 } } } }
附: