|
#include<reg51.h>
#define uchar unsigned char
#define uint unsigned int
uchar linenum,x;
void delay(uint x)
{
uint a;
for(a=x;a>0;a--);
}
void djkz()
{
switch(linenum)
{
case 0: P2=0X01; break;
case 1: P2=0X03; break;
case 2: P2=0X07; break;
case 3: P2=0X0F; break;
case 4: P2=0X1F; break;
case 5: P2=0X3F; break;
case 6: P2=0X7F; break;
case 7: P2=0XFF; break;
default: P2=0X00; break;
}
}
void main()
{
EA=1;
EX1=1;
IT1=1;
//IE=0X84;
//TCON=0X04;
while(1)
{
djkz();
}
}
void exter0() interrupt 2 using 2
{
delay(500);
if(INT1==0)
{
delay(500);
linenum=linenum+1;
delay(500);
if(linenum==12) linenum=0;
}
}
|
|