花样灯

来源:互联网 发布:thinkphp nginx 配置 编辑:程序博客网 时间:2024/04/17 03:50


#include <reg52.h>


void Delay(unsigned int c);   //延时10ms


unsigned char LED;




void main()

unsigned char i;


 
LED = 0xFE;


while (1) 
{  
  
for (i = 0 ;i < 7 ; i++)


P0  = LED;

Delay(50000);

LED = LED << 1;    

LED = LED | 0x01; 
}


for (i = 0 ;i < 7 ; i++)
{
P0  = LED;


Delay(50000);


LED = LED >> 1;// 右移


LED = LED | 0x80;
}


P0 = 0x00;
Delay(50000);
P0 = 0xff;
Delay(50000);





}
 
}






void Delay(unsigned int c)   
{
    for (;c>0;c--)
{
           
}       
}
0 0
原创粉丝点击