部分程序
#include <reg51.h>
#include "intrins.h"
#define uint unsigned int //宏定義
#define uchar unsigned char //宏定義
uchar i=0,j=0,k=0, s=1,f=1,m=0,a[9]; //定義變量
sbit K4=P1^3; //位定義
sbit K5 =P1^4; //位定義
sbit fmq =P3^6; //位定義
sbit DQ=P3^3; //溫度輸入口
sbit DIN=P0^7;
uint h;
uint temp;
uint num;
uint numc;
//uchar code sz[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0xbf} ; //數字編碼表
//uchar code xw[]={ 0xff,0xfe,0xfd,0xfb,0xf7, //選位編碼表
//0xef,0xdf,0xbf,0x7f
//};
//**************溫度小數部分用查表法***********//
uchar code ditab[16]=
{0x00,0x01,0x01,0x02,0x03,0x03,0x04,0x04,0x05,0x06,0x06,0x07,0x08,0x08,0x09,0x09};
//
uchar code dis_7[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0xff,0xbf};
//共陽LED段碼表 "0" "1" "2" "3" "4" "5" "6" "7" "8" "9" "不亮" "-"
uchar code scan_con[8]={0xf7,0xfb,0xfd,0xfe,0xef,0xdf,0xbf,0x7f}; //列掃描控制字
uchar data temp_data[2]={0x00,0x00}; //讀出溫度暫放
uchar data display[10]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; //顯示單元數據,共4個數據和一個運算暫用
//uchar data display1[5]={};
//
//
//
void pf() //區分出個位和十位
{
a[1]=s/10;
a[2]=s%10;
a[3]=11;
a[4]=f/10;
a[5]=f%10;
a[6]=11;
a[7]=m/10;
a[8]=m%10;
}
/*****************11us延時函數*************************/
//
void delay(uint t)
{
for (;t>0;t--);
}
/*****************延時函數***********************/
void ys ( int d )
{
int b ,c ;
for (b = d;b>0;b--)
for (c=110;c>0;c--) ;
}
//****************1ms基準延時程序
void delay1ms(uint i)
{
uchar j;
while(i--)
{
for(j=0;j<115;j++)
|