只想讓中斷的時(shí)候亮一盞燈,結(jié)果二極管亂亮
#include <reg52.h>
#define uint unsigned int
#define uchar unsigned char
void delay(uint);
sbit weiloc=P2^7;
sbit duanloc=P2^6;
uchar code table[]={0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,
0x39,0x5e,0x79,0x71};
uchar c;
sbit sj=P1^4;
sbit D1=P0^0;
void main()
{
EA=1;
EX0=1;
sj=0;
weiloc=1;
P0=0x00;
weiloc=0;
while(1)
{
for(c=0;c<16;c++)
{
D1=1;
duanloc=1;
P0=table[c];
duanloc=0;
delay(1000);
}
}
}
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
void exter() interrupt 0
{
D1=0;
}
|