#include
unsigned char temp[10] = {0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f}
unsigned char table[3];
unsigned int num;
void display(unsigned int num)
{
table[0] = temp[num / 100]
table[1] = temp[num / 10 % 10 ] | 0x80;
table[2] = temp[num % 10]
}
void main()
{
EA = 1;
TMOD |= 0x21;
TH0 = 0xfc;
TL0 = 0x18;
ET0 = 1;
TR0 = 1;
while(1)
{
display(num);
}
}
void timer0() interrupt 1//定时为2ms
{
static unsigned char i = 0;
static unsigned int j = 0;
TH0 = 0xfc;
TL0 = 0x18;
j++;
if(i < 3)
{
P2 = 0xf8;
P1 = 0x00;
P2 = ~(1 << i);
P1 = table1[i];
i++;
}
else
i = 0;
if(j >= 1000)
{
num++;
if(num > 999)
num = 0;
j = 0;
}
用的是共阴极数码管,定时器延时,不会出现数码管抖动现象
定时器自动加,会从0.00-9.99自动显示,9.99以后又清0.00
写过ADC0809的程序。
在百度 网页中搜索:
做而论道 ADC0809
百度一下,即可找到。