@[TOC](文章目录)
@TOC
基于51单片机病床呼叫系统仿真设计(protues仿真+源码+报告)
仿真图protues 8.9
程序编译器:keil 4/keil 5
编程语言:C语言
设计编号:C0047
具体功能:
应用所学单片机知识,搭建一个病床呼叫系统设计,功能要求如下
(1)当病人紧急呼叫时,会产生声、光提示,并显示病人编号(房间号和床号);
(2)根据病人病情设置优先级,当有多人呼叫时,先呼叫的优先处理;
(3)医护人员处理完当前呼叫后,系统按呼叫顺序显示其它呼叫病人的号码;
(4)可设定呼叫倒计时,总床位数为24个。
资料下载(可点击)
仿真图(提供源文件):

程序(提供源文件源码):
main函数
#include <reg52.h>
#include "key.h"
#include "delay.h"
#define uint unsigned int
#define uchar unsigned char
sbit key1=P3^0;
uint code shu[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90}; //共阳极段码
uint code wei[]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80}; //位选
uchar mm,ss,pp;
void Timer0Init(void) //定时器初始化
{
TMOD=0x01;
TH0=(65536-18000)/256;
TL0=(65536-18000)%256;
TR0=1;
ET0=1;
EA=1;
}
void main()
{
uchar tt,i,j,aa=1;
uchar num[30];
P0=0x00;
P2=0x00;
Timer0Init();
while(1)
{
tt = keynum();
if(tt!=num[i]&&tt!=0)
{
num[++i] = tt;
}
if(key1==0)
{
DelayMS(1);
if(key1==0)
{
while(!key1);
aa++;
ss=0;
mm=0;
beep=0;
led=0;
}
}
if(num[aa]!=0)
{
TR0=1;
P2 = wei[7];
P0 = shu[num[aa]/10];
DelayMS(1);
P2 = wei[5];
P0 = shu[num[aa]%10];
DelayMS(1);
P2 = wei[2];
P0 = shu[ss/10];
DelayMS(1);
P2 = wei[3];
P0 = shu[ss%10];
DelayMS(1);
P2 = wei[0];
P0 = shu[mm/10];
DelayMS(1);
P2 = wei[1];
P0 = shu[mm%10];
beep=1;
led=1;
if(ss==60)
{
ss=0;
mm++;
}
}
else
{
P2=0x00;
ss=0;
aa=1;
for(j=0;j<i+1;j++)
num[j]=0;
i=0;
TR0=0;
}
}
}
void T0_time() interrupt 1
{
TR0=0;
TH0=(65536-18000)/256;
TL0=(65536-18000)%256;
pp++;
if(pp==40) {ss++;pp=0;}
TR0=1;
}
按键驱动函数
#include <reg52.h>
#include "delay.h"
unsigned char keynum(void)
{
static unsigned char key;
P3=0x7f;
DelayMS(10);
if(P1!=0xff)
{
key=1;
beep=1;led=1;
}
else
{
P3=0xbf;
DelayMS(10);
if(P1!=0xff)
{
key=2;
}
else
{
P3=0xdf;
DelayMS(10);
if(P1!=0xff)
{
key=3;
}
else key=0;
}
}
switch(P1)
{
case 0xfe : key=key*10+1;break;
case 0xfd : key=key*10+2;break;
case 0xfb : key=key*10+3;break;
case 0xf7 : key=key*10+4;break;
case 0xef : key=key*10+5;break;
case 0xdf : key=key*10+6;break;
case 0xbf : key=key*10+7;break;
case 0x7f : key=key*10+8;break;
default : break;
}
return key;
}
设计报告:
资料清单(提供资料清单所有文件)
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 嘉盛单片机!