#include <at89x52.h>
#define DO P3_7
#define SEG P0 //数码管自左至右依次为 1234 位
#define MS2L 0x18 //1ms 的延时参数
#define MS2H 0xfc
#define uchar unsigned char
#define uint unsigned int
uchar code comm[4] = {0x01,0x02,0x04,0x08};
uchar code seg[10] = {0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
uchar code seg_add_dicimal[10] = {0x40,0x79,0x24,0x30,0x19,0x12,0x02,0x78,0x00,0x10};
uchar code seg_dicimal[2] ={0xc0, 0x92};
uchar k = 0;
uchar temp_l = 0;
uchar temp_h = 0;
uchar tempsign = 0;
uchar hundreds = 0;
uchar tens = 0;
uchar ones = 0;
uchar low_four = 0;
/*延时以 ms 为单位的 t 时间*/
void Delay(uint t)
{
uint i;
while(t--)
{
for(i=0; i<125; i++)
{ }
}
}
/*us 级延时,延时时间约 4+2*i*/
void Delayus(uchar i)
{
while(--i);
}
学习文档 仅供参考