中断响应流水灯控制程序

#include<reg51.h>
void delay(unsigned int i);
int main(void) using 0
{
	int i=1;
	EA=1;
	EX0=1;
	IT0=1;
	P0=~0;
	while(1)
	{
		for(;i<=128;i*=2)
		{
			P0&=~i;
			
		delay(500);
			P0|=i;
		}
		i=1;
	}
	while(1);
}
void delay(unsigned int i)
{
	unsigned int j;
	for(;i>0;i--)
	   for(j=0;j<333;j++);
}
void int0()interrupt 0 using 1
{
	int i=0;
	EX1=0;
	for(i;i<=2;i++)
	{
		P0=0;
		delay(100);
		P0=~0;
		delay(100);
	}
	EX1=1;
}

posted on 2017-12-11 11:13  MACHINE_001  阅读(1524)  评论(0编辑  收藏  举报

导航