要求:八个灯一开始全灭,每按一次加一键灯就多亮一盏,八个灯全亮后每按一次减一键灯就灭一盏。谢谢
#include <reg51.h>
#define uchar unsigned char
uchar code table[]={0xff,0xfe,0xfc,0xf8,0xf0,0xe0,0xc0,0x80,0x00};
uchar i;
void main()
{
IT0=1;
EX0=1;
IT1=1;
EX1=1;
EA=1;
while(1)
{
P2=table[i];
}
}
void t0()interrupt 0
{
i++;
if(i==9)
i=0;
}
void t1()interrupt 2
{
i--;
if(i==255)
i=8;
}