51实验3:总线法写闪烁灯

51实验3:总线法写闪烁灯

#include <reg52.h>

void delay300ms(void)   
{
    unsigned char a,b,c;
    for(c=123;c>0;c--)
        for(b=116;b>0;b--)
            for(a=9;a>0;a--);
}

void main()
{
   while(1)
	 {
		 P2=0x55;
		 delay300ms();
		 P2=~P2;
		 delay300ms();
		 P2=0x00;
		 delay300ms();
		 P2=0xff;
		 delay300ms();
		 P2=0xc3;
		 delay300ms();
		 P2=~P2;
		 delay300ms();
		 P2=0xe7;
		 delay300ms();
		 P2=~P2;
		 delay300ms();
	 }
}

猜你喜欢

转载自blog.csdn.net/wang2395/article/details/107435733