標(biāo)題:
基于AT89c52的脈搏檢測程序
[打印本頁]
作者:
24sada1e1
時間:
2017-6-10 16:29
標(biāo)題:
基于AT89c52的脈搏檢測程序
單片機(jī)脈搏檢測源程序如下:
unsigned char key_value; //存放鍵盤返回
unsigned char key_flag=0;//定義有鍵按下的標(biāo)志
unsigned char i,j,t,m,DelayTime,DispBuf[3];
unsigned int n,mb;
#include "reg52.h"
#include "lcd.c"
#include "hardware.c"
#include "user.c"
#include "key.c"
#include "string.h"
#include "intrins.h"
void delay(DelayTime);
void main()
{
EA=0;
LCD_Initial();
delay_20ms(10);
LCD_Write(0,0x01); //清屏
LCD_Print(5,0,"Welcome!");
delay_20ms(10);
LCD_Print(0,0,"MaiBoCeLiang");
LCD_Print(0,1,"e Control!");
delay_20ms(10);
LCD_Write(0,0x01); //清屏
LCD_Print(0,0,"LSTC");
LCD_Print(0,1,"by LWL&MZL");
delay_20ms(10);
LCD_Write(0,0x01); //清屏
TMOD=0x01; //定時器T0工作于方式1
TH0=0xec;
TL0=0x78; //T0定時時間為5ms
IE=0X83; //開中斷
IT0=1; //外部中斷0為邊沿觸發(fā)方式
TR0=1; //開定時器T0
for(;;) //脈搏指示燈控制
{
if(P3_0==0)
{
delay(200);
P3_0=1;
}
}
}
external0() interrupt 0//外部中斷服務(wù)程序
{
P3_0=0; //點(diǎn)亮指示燈
if(n==0)
mb=0;
else
mb=12000/n; //計算每分鐘脈搏數(shù)
DispBuf[2]=mb%10;//取個位數(shù)
mb=mb/10;
DispBuf[1]=mb%10;//取十位數(shù)
DispBuf[0]=mb/10;//取百位數(shù)
n=0;
}
Timer0() interrupt 1//定時中斷服務(wù)程序
{
TH0=0xec;
TL0=0x78;
t=BitTab[j];//取位值
P3=P3|0x38;//P3.3-P3.5送1
P3=P3&t; //P3.3-P3.5輸出取出的位值
t=DispBuf[j];//取出待顯示的數(shù)
t=DispTab[t];//取字形碼
P1=t; //字型碼由P3輸出顯示
j++; //j作為數(shù)碼管的計數(shù)器,取值0-2,顯示程序通過它確認(rèn)顯示哪個數(shù)碼管
if(j==3)
j=0;
n++;
if(n==2000)//10秒鐘測不到心率,n復(fù)位
n=0;
}
……………………
…………限于本文篇幅 余下代碼請從51黑下載附件…………
復(fù)制代碼
所有資料51hei提供下載:
脈搏程序.rar
(22.63 KB, 下載次數(shù): 29)
2017-6-10 16:28 上傳
點(diǎn)擊文件名下載附件
脈搏檢測
下載積分: 黑幣 -5
歡迎光臨 (http://www.torrancerestoration.com/bbs/)
Powered by Discuz! X3.1