国产免费AV|泡泡玛特欧洲总部将设在伦敦|中文天堂网www新版资源在线|一本久道综合在线中文|国精产品一二三产区的使用方法|香蕉鱼在线观看|www.27eee
ELEOK
標題:
51單片機+ST188脈搏體溫測量C源程序
[打印本頁]
作者:
coolfire
時間:
2021-5-6 01:42
標題:
51單片機+ST188脈搏體溫測量C源程序
電路原理圖如下:
1.png
(129.38 KB)
下載附件
2021-5-6 01:39 上傳
元件清單
1、萬用板
2、單片機
3、Lcd1602液晶屏
4、16p排針
5、16p排針母座
6、LM358芯片
7、40腳IC座
8、8腳IC座
9、ST188反射光電開關
10、防水型DS18B20
11、200歐電位器
12、220歐電阻*2
13、1k電阻*5
14、2k電阻
15、10k電阻*6
16、20k電阻
17、100k電阻
18、1uf電容*2
19、10uf電容*2
20、12m晶振
21、30pf電容*2
22、紅色led燈*3
23、綠色led燈
24、黃色led燈
25、8550三極管
26、蜂鳴器
27、按鍵*4
28、自鎖開關
29、DC3.5mm電源座
30、焊錫若干
31、導線若干
32、usb電源線
單片機部分源程序如下:完整程序見附件
#include<reg52.h>
#include <intrins.h>
#include <string.h>
#include "lcd1602.h"
#include "ds18b20.h"
#include "eeprom.h"
#define uchar unsigned char
#define uint unsigned int
sbit rled = P1^0;
sbit gled = P1^1;
sbit trled = P1^2;
sbit yled = P1^3;
sbit beep = P1^4;
sbit key1 = P1^5;
sbit key2 = P1^6;
sbit key3 = P1^7;
sbit P32=P3^2;
unsigned char i=0,timecount=0,displayOK=0,rate=0,aa=0;
unsigned int time[6]={0};
uint temp;
uchar flag;
uchar xl_h,xl_l,temp_h,temp_l;
uint alt;
bit S_flag;
void delay(uint j)
{
uint x,y;
for(x=0;x<j;x++)
for(y=0;y<110;y++);
}
/******************把數據保存到單片機內部eeprom中******************/
void write_eeprom()
{
SectorErase(0x2000);
byte_write(0x2000, xl_h);
byte_write(0x2001, xl_l);
byte_write(0x2002, temp_h);
byte_write(0x2003, temp_l);
byte_write(0x2058, a_a);
}
/******************把數據從單片機內部eeprom中讀出來*****************/
void read_eeprom()
{
xl_h = byte_read(0x2000);
xl_l = byte_read(0x2001);
temp_h = byte_read(0x2002);
temp_l = byte_read(0x2003);
a_a = byte_read(0x2058);
}
/**************開機自檢eeprom初始化*****************/
void init_eeprom()
{
read_eeprom(); //先讀
if(a_a != 1||key2==0) //新的單片機初始單片機內問eeprom
{
xl_h = 90;
xl_l = 50;
temp_h =37;
temp_l =15;
a_a = 1;
write_eeprom(); //保存數據
}
}
void display()
{
if(flag==0)
{
lcd1602_write(0,0x80);
lcd1602_writebyte(" Temp:");
lcd1602_write(1,0x30 + temp/100);
lcd1602_write(1,0x30 + temp%100/10);
lcd1602_write(1,'.');
lcd1602_write(1,0x30 + temp%10);
lcd1602_write(1,0xdf);
lcd1602_writebyte("C ");
lcd1602_write(0,0xc0);
lcd1602_writebyte("Heart:");
if(displayOK==1)
{
rate=60000/(time[1]/5+time[2]/5+time[3]/5+time[4]/5+time[5]/5);
lcd1602_write(1,0x30 + rate/100);
lcd1602_write(1,0x30 + rate%100/10);
lcd1602_write(1,0x30 + rate%10);
}
else
{
lcd1602_writebyte("---");
}
lcd1602_writebyte("/min ");
}
else
{
lcd1602_write(0,0x80);
lcd1602_writebyte(" XH:");
if(S_flag==1&&flag==1)
lcd1602_writebyte(" ");
else
{
lcd1602_write(1,0x30 + xl_h/100);
lcd1602_write(1,0x30 + xl_h%100/10);
lcd1602_write(1,0x30 + xl_h%10);
}
lcd1602_writebyte(" XL:");
if(S_flag==1&&flag==2)
lcd1602_writebyte(" ");
else
{
lcd1602_write(1,0x30 + xl_l/100);
lcd1602_write(1,0x30 + xl_l%100/10);
lcd1602_write(1,0x30 + xl_l%10);
}
lcd1602_write(0,0xc0);
lcd1602_writebyte(" TH:");
if(S_flag==1&&flag==3)
lcd1602_writebyte(" ");
else
{
lcd1602_write(1,0x30 + temp_h/10);
lcd1602_write(1,0x30 + temp_h%10);
}
lcd1602_writebyte("C ");
lcd1602_writebyte(" TL:");
if(S_flag==1&&flag==4)
lcd1602_writebyte(" ");
else
{
lcd1602_write(1,0x30 + temp_l/10);
lcd1602_write(1,0x30 + temp_l%10);
}
lcd1602_writebyte("C ");
}
}
void keyrc()
{
if(key1==0)
{
delay(10);
if(key1==0)
{
flag++;
if(flag>4) flag=0;
}
while(!key1);
}
if(key2==0)
{
delay(10);
if(key2==0)
{
switch(flag)
{
case 1: if(xl_h<160) xl_h++; break;
case 2: if(xl_h>xl_l+1) xl_l++; break;
case 3: if(temp_h<99) temp_h++; break;
case 4: if(temp_h>temp_l+1) temp_l++; break;
}
write_eeprom();
}
while(!key2);
}
if(key3==0)
{
delay(10);
if(key3==0)
{
switch(flag)
{
case 1: if(xl_h>xl_l+1) xl_h--; break;
case 2: if(xl_l>0) xl_l--; break;
case 3: if(temp_h>temp_l+1) temp_h--; break;
case 4: if(temp_l>0) temp_l--; break;
}
write_eeprom();
}
while(!key3);
}
}
void clsp()
{
alt++;
if(alt>15)
{
alt=0;
if(displayOK==1)
{
if(rate>xl_h) {rled=~rled;gled=1;}
else if(rate<xl_l) {rled=1;gled=~gled;}
else {rled=1;gled=1;}
}
else {rled=1;gled=1;}
if(temp>temp_h*10) {trled=~trled;yled=1;}
else if(temp<temp_l*10) {trled=1;yled=~yled;}
else {trled=1;yled=1;}
if(((rate>xl_h || rate<xl_l) && displayOK==1) || temp>temp_h*10 || temp<temp_l*10)
beep=~beep;
else
beep=1;
S_flag=~S_flag;
}
}
void main()
{
P32=1;
lcd_init();//lcd初始化
init_eeprom();
TCON=0x01;//設置外部中斷0
EX0=1;
TMOD=0x01;//定時器0初始化
TL0 = 0xB0; //設置定時初值
TH0 = 0x3C; //設置定時初值
ET0=1;//開定時器中斷
//顯示基本文字
temp=ReadTemperature();
GoToXY_string(0,0," Welcome to use ");
GoToXY_string(1,0," Heart rate ");
TR0=0;//定時器停止
EA=1;//開總中斷
delay(2000);
temp=ReadTemperature();
while(1)
{
temp=ReadTemperature();
display();
keyrc();
clsp();
}
}
……………………
…………限于本文篇幅 余下代碼請下載附件…………
復制代碼
完整程序代碼.rar
(63.35 KB, 售價: 2 E幣)
2021-5-6 01:41 上傳
點擊文件名下載附件
售價: 2 E幣
[記錄]
[
購買
]
歡迎光臨 ELEOK (http://www.afoofa.cn/)
Powered by Discuz! X5.0