#define
uchar
unsigned
char
#define
uint
unsigned
int
uchar
count
uint
disnum
sbit
dula=P2^6
sbit
wela=P2^7
uchar
code
tabledu[]={
0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,
0x39,0x5e,0x79,0x71}
display(uchar,uchar,uchar)
delay(uchar)
void
main()
{
EA=1
ET1=1
TMOD=0x10
TH1=(65536-50000)/256
TL1=(65536-50000)%256
TR1=1
while(1)
{
if(count==20)
{
count=0
//
if(disnum==1000)
//
disnum=0
disnum++
}
display(disnum/100,disnum%100/10,disnum%100%10)
}
}
void
tim1()
interrupt
3
using
3
{
TH1=(65536-50000)/256
TL1=(65536-50000)%256
count++
}
display(uchar
bai,uchar
shi,uchar
ge)
{
P0=tabledu[bai]
dula=1
dula=0
P0=0xfe
wela=1
wela=0
delay(1)
P0=tabledu[shi]
dula=1
dula=0
P0=0xfd
wela=1
wela=0
delay(1)
P0=tabledu[ge]
dula=1
dula=0
P0=0xfb
wela=1
wela=0
delay(1)
}
delay(uchar
x)
{
uchar
a,b
for(a=xa>0a--)
for(b=255b>0b--)
}
//你自己看一下,有不对的就改点.别忘了给分啊
主要程序如下:uchar table[8]={1,3,5,7,2,4,6,8}//要显示的数字
uchar qiduan_tab[10]={.........}//七段码
while(1)
{
for(i=0i<5i++)//先显示1357,第二次显示3572 第三次显示5724
{
for(j=0j<20j++)//刷新20次约0.4秒,推进一位
{
wei1=0P0= table[qiduan_tab[ i]delayms(5)wei1=1
wei2=0P0= table[qiduan_tab[ i+1]delayms(5)wei2=1
wei3=0P0= table[qiduan_tab[ i+2]delayms(5)wei3=1
wei4=0P0= table[qiduan_tab[ i+3]delayms(5)wei4=1
}
}
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)