#include "reg51.h"
#include "intrins.h" //延时函数用
#define Disdata P1 //段码输出口
#define discan P3 //扫描口
#define uchar unsigned char
#define uint unsigned int
sbit DQ=P3^7; //温度输入口
sbit DIN=P1^7; //LED小数点控制
uint h;
uchar code ditab[16]={0x00,0x01,0x01,0x02,0x03,0x03,0x04,0x04,0x05,
0x06,0x06,0x07,0x08,0x08,0x09,0x09};//温度小数部分用查表法
uchar codedis_7[12]={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[4]={0xfe,0xfd,0xfb,0xf7}; // 列扫描控制字
uchar data temp_data[2]={0x00,0x00}; // 读出温度暂放
uchar data display[5]={0x00,0x00,0x00,0x00,0x00};//显示单元数据,共4个数据,一个运算暂存用
void delay(uint t)//11微秒延时函数
{ for(;t>0;t--); }
scan()//显示扫描函数
{ char k;
for(k=0;k<4;k++) //四位LED扫描控制
{ Disdata=dis_7[display[k]];
if(k==1){DIN=0;}
discan=~scan_con[k];delay(90);discan=0x00;
}
}