基于51单片机病床呼叫系统Proteus仿真设计


本设计包含protues仿真+程序代码+设计报告

📚开发环境

仿真图:protues 8.9
程序编译器:keil 4/keil 5
编程语言:C语言
设计编号:C0047

📚 具体功能

应用所学单片机知识,搭建一个病床呼叫系统设计,功能要求如下
(1)当病人紧急呼叫时,会产生声、光提示,并显示病人编号(房间号和床号);
(2)根据病人病情设置优先级,当有多人呼叫时,先呼叫的优先处理;
(3)医护人员处理完当前呼叫后,系统按呼叫顺序显示其它呼叫病人的号码;
(4)可设定呼叫倒计时,总床位数为24个。

📚 仿真图

image-20220903174015625
image-20220903174025796

📚 程序代码

image-20220903174417168

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;
}

📚设计报告

image-20220903174431112

📚资料清单&下载链接

image-20220903174442456

资料下载(可点击):
https://docs.qq.com/doc/DS3FKTlNGam1ZZ01s

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值