新手!晶体管显示数字一到九,间隔一秒,用中断实现
时间:10-02
整理:3721RD
点击:
#include<reg51.h>
#define LEDPort P0
unsigned char a;
unsigned char DisCA[10]={0xC0,0xF9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
unsigned char DisCC[10]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
void T0_ISR() interrupt 1
{
TH0=15536/256;
TL0=15536%256;
a=0;
if(a==20)
{
unsigned char i=0;
for(i=0;i<10;i++)
{
LEDPort=DisCC[i];
}
a++;
}
}
void main()
{
TMOD=0X01;
TH0=15536/256;
TL0=15536%256;
EA=1;
ET0=1;
TR0=1;
while(1);
}
哪里错了?
#define LEDPort P0
unsigned char a;
unsigned char DisCA[10]={0xC0,0xF9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
unsigned char DisCC[10]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
void T0_ISR() interrupt 1
{
TH0=15536/256;
TL0=15536%256;
a=0;
if(a==20)
{
unsigned char i=0;
for(i=0;i<10;i++)
{
LEDPort=DisCC[i];
}
a++;
}
}
void main()
{
TMOD=0X01;
TH0=15536/256;
TL0=15536%256;
EA=1;
ET0=1;
TR0=1;
while(1);
}
哪里错了?
菜鸟求解。不胜感激....
好熟悉,顶下!
你中断里面a=0;每次进中断A都清零了 怎么能到if(a==20)?
而且你把a++放在了if(a==20)里面了