为什么一按中断想让时间的分位+1,但是一按那个数码管就变暗了???
#include<reg51.h>
#define uint unsigned int
#define uchar unsigned char
#define LED_PORT P0
uchar code table[]={
0x3f , 0x06 , 0x5b , 0x4f , 0x66 , 0x6d ,
0x7d , 0x07 , 0x7f , 0x6f , 0x77 , 0x7c ,
0x39 , 0x5e , 0x79 , 0x71 , 0x00};
uchar code d_table[]={
0x3f , 0x06 , 0x5b , 0x4f , 0x66 , 0x6d ,
0x7d , 0x07 , 0x7f , 0x6f };//共阴0~F段码
uchar code w_table[]={
0xff,0xfe,0xfd,0xfb,0xf7,0xef,0xdf};//1-6位选码
void delay(uint z);
sbit duan=P2^6;
sbit wei=P2^7;
uchar a,b,l,i,j,k,w,z;
void init();
void main()
{
init();
j=k=w=0;
a=1;b=2;l=3;z=0;
while(1)
{
if(z==30)
{
i++;
z=0;
}
w++;
LED_PORT=w_table[1];
wei=1;
wei=0;
LED_PORT=d_table[a];
duan=1;
duan=0;
delay(5);
LED_PORT=w_table[2];
wei=1;
wei=0;
LED_PORT=d_table
;
duan=1;
duan=0;
delay(5);
if(b==9)
{
b=0;
a++;
}
LED_PORT=w_table[3];
wei=1;
wei=0;
LED_PORT=d_table[l];
duan=1;
duan=0;
delay(5);
if(l==6)
{
l=0;
b++;
}
LED_PORT=w_table[4];
wei=1;
wei=0;
LED_PORT=d_table[k];
duan=1;
duan=0;
delay(5);
if(k==9)
{
k=0;
l++;
}
LED_PORT=w_table[5];
wei=1;
wei=0;
LED_PORT=d_table[j];//miao
duan=1;
duan=0;
delay(5);
if(j==6)
{
j=0;
k++;
}
LED_PORT=w_table[6];
wei=1;
wei=0;
LED_PORT=d_table;//miao
duan=1;
duan=0;
delay(5);
if(i==10&&w!=0)
{
i=0;
j++;
}
z++;
}
}
void init()
{
IT0=0;
EA=1;
EX0=1;
LED_PORT=0xff;
wei=1;
wei=0;
}
void delay(uint z)
{
uint i,j;
for(j=z;j>0;j--)
for(i=110;i>0;i--);
}
void inter0() interrupt 0
{
k++;
}
-
protues.......................
一周热门 更多>