|
我的意思是想让其数码管以0~60循环显示数字但是最后只能显示个位或十位
而且位选也错了我叫它往东它却往西让后又往北!!
从早上写到晚上21点 改了好久好久 其结果是要么控制各位要么控制十位...
达不到我所要求的工作目的!! 瞬间明白为什么程序员爱加班了。。。而且有时加班时间超过14个小时............
#include<reg51.h>
#define uchar unsigned char
#define uint unsigned int
uchar aa,ss,ge,shi;
uchar code shuzi[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
sbit a=P1^0;
sbit b=P1^1;
void time(uchar k);
void display(ge,shi);
void display(ge,shi);
void main()
{
TMOD=0x01;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
EA=1;
IT0=1;
ET0=1;
TR0=1;
P1=0;
P2=0;
while(1)
{
P1=0;
P2=0;
display(ge,shi);
}
}
void display(ge,shi)
{
a=1;
P2=shuzi[ge];
time(1);
P2=0;
a=0;
b=1;
P2=shuzi[shi];
time(1 );
P2=0;
b=0;
}
void time(uchar k)
{
uchar x,y;
for(x=100;x>0;x--)
for(y=k;y>0;y--);
}
void dsq0() interrupt 1
{
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
aa++;
if(aa==20)
{
aa=0;
ss++;
if(ss==60)
{
ss=0;
}
shi=ss/10;
ge=ss%10;
}
}
设计者:薛羽豪
|
|