# include<REG51.H>
#include<intrins.h>
#define uchar unsigned char
#define uint unsigned int
uchar i;
//= = = = = = = = = = = =
void DelayMS(uint x) //延时
{
uchar i;
while(x--) for(i=0;i<120;i++);
}
//= = = = = = = = = = = =
int1() interrupt 2 //K1中断程序
{char k;
for(k=0;k<=2;k++)
{P0=0x00; //发光二极管全亮
DelayMS(150);
P0=0xFF; //发光二极管全灭
DelayMS(150);
}
}
//= = = = = = = = = = = = = =
void main()
{
IT1=0;
EX1=1;
EA=1;
P0=0xfe;
while(1)
{DelayMS(150);
P0=_crol_(P0,1); //P0 的值向左循环移动
DelayMS(150);
} }
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
我说错了。。不是5次是3次。。你说的应该是有道理的。。可是如果我在下面也加个初值。
void main(void)
{
IT1=0;
EX1=1;
EA=1;
P0=0xfe;
while(1)
{ P0=0xfe;
DelayMS(1500);
P0=_crol_(P0,1); //P0 的值向左循环移动
DelayMS(1500);
}
}
就会最初不是8个灯循环走,是2个灯了。虽然中断后能回来了。
一周热门 更多>