人体温度非接触式测量仪
write_com(0x01); //清屏 write_Chinese(0,0,table1,7); //显示汉字现在得室温 delayms(20); write_Chinese(1,4,table4,3); //摄氏度 while(1) { temperature1=read_temp(); //读取温度 temp_show0(temperature1); //显示环境温度 delayms(500); if(body==0) break; } } } }
引脚定义数组定义 data.h #ifndef DATA_H #define DATA_H
#define uchar unsigned char #define uint unsigned int
sbit lcden=P3^4; //引脚定义 sbit lcdrs=P3^5; sbit SS = P1^4; sbit SCLK= P1^0; sbit MOSI= P1^2; sbit MISO= P1^1; sbit RAC = P1^3; sbit body=P1^5; sbit audio=P1^6;
uchar code numb[]={0,1,2,3,4,5,6,7,8,9,}; uchar code table0[]={\欢迎使用测温仪!%uchar code table1[]={\现在的室温是:%uchar code table2[]={\您的体温是:%uchar code table3[]={\测量失败请重试%uchar code table4[]={\摄氏度\
//查表
unsigned int code tiwen[]={
//检测测量标志 - 37 -
人体温度非接触式测量仪
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //0~24 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //25~49 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //50~74 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,//75~92 0,1,1,2,3,4,5,6,6,7,8,8,9,9,//93~106
10,10,11,12,13,14,15,15,16,17,18,18,19,//107~109 20,21,22,22,23,24,24,25,26,26,27,28,29,29,//120~133 30,31,32,32,33,34,35,36,37,37,38,39,39,//134~146 40,41,42,42,43,44,45,45,46,47,48,49,49,//147~159 50,51,52,52,53,54,55,55,56,57,58,58,59,//160~172 60,60,61,62,63,64,64,65,66,67,68,68,69,//173~185 70,71,71,72,73,74,75,75,76,77,78,78,79,//186~198 80,80,81,82,83,83,84,85,86,87,87,88,89,//199~211 90,91,91,92,93,94,95,95,96,97,98,98,99,//212~224
100,100,101,102,103,104,104,105,106,107,108,109,109,//225~237 110,111,111,112,113,114,115,116,117,117,118,119,119,//238~250 120,121,122,122,123};//251~255 #endif
延时函数delay.h #ifndef DELAY_H #define DELAY_H
void delay(unsigned int i) //延时程序 {
while(i--); }
void delayms(unsigned int MS)//延时毫秒 { unsigned char us,usn; while(MS!=0) { usn=2; while(usn!=0) { us=0xf6; while(us!=0) {us--;} usn--; } MS--; }
- 38 -
人体温度非接触式测量仪
}
#endif
1T单片机专用延时函数 delay1T.h #ifndef DELAY1T_H #define DELAY1T_H /*
* 函 数 名:DelayUs1T
* 功能描述:1T单片机us级延时,2us~85us,精度1us
* 输入参数:delayUsVal = 3t - 3 min=2
* 返 回 值:无 */
void DelayUs1T(unsigned char delayUsVal) {
while (--delayUsVal); } /*
* 函 数 名:DelayMs1T
* 功能描述:1T单片机ms级延时
* 输入参数:delayMsVal=t 延时多少ms,1ms~65535ms
* 返 回 值:无 */
void DelayMs1T(unsigned int delayMsVal) {
unsigned char i, j;
- 39 -
人体温度非接触式测量仪
while (delayMsVal--)
for (i = 0; i<10; i++)
for (j = 0; j<169; j++); }
#endif
DS18B20子程序ds18b20.h #ifndef DS18B20_H #define DS18B20_H
#include
#define nops(); {_nop_(); _nop_(); _nop_(); _nop_();} //定义空指令
sbit DQ=P3^7;
static unsigned char temp_data[2]={0x00,0x00}; // 读出温度暂放
void Delay15(unsigned char n)
{ do{ _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); n--;
}while(n); }
void DelayX0us(unsigned char n) {
while (n--) {
_nop_();
- 40 -

