你等等,晚上做实物。看附件里这个行不,有程序,望采纳。
就是这样的,编程怎么编啊
追答采纳,给你发
#include
#define uchar unsigned char
#define uint unsigned int
char code dm[]={0x28,0xEB,0x32,0xA2,0xE1,0xA4,0x24,0xEA,0x20,0xA0};//数字对应的段码
unsigned char scan[]={0x7F,0xBF,0xDF,0xEF,0xF7,0xFB,0xFD,0xFE}; //1到8,逐个扫描数码管 接P0口
int c;
uint b=100;
/////////////////////////////////////
void delay(uint t)
{
uint i;
while(t--)
{
for (i=0;i<125;i++)
{ }
}
}
void display(char t)
{
P0=dm[(t/100)%10];P2=scan[0];delay(3);
P0=dm[(t%100)/10];P2=scan[1];delay(3);
P0=dm[t%10];P2=scan[2];delay(3);
}
/////////////////////////////////////////
void main(void)
{
TMOD=0X01;
TH0=-(1000/256);
TL0=-(1000%256);
EA=1;ET0=1;TR0=1;
while(1)
{
display(b);
}
}
///////////////////////////////////////////////////
void timer0( ) interrupt 1 /*interrupt和1之间有一空格!*/
{
TL0=-(1000%256); //为了精确,TL0写在TH0前,且初值设高一点点
TH0=-(1000/256);
c++;
if(c==800) {c=0;b--;if(b==0) b=100;}
}