- #include<reg51.h>
- #include<math.h>
- unsigned char a=0xfe;
- unsigned char b=0;
- void delay(unsigned char i)
- {
- unsigned char j,k;
- for(j=i;j>0;j--)
- for(k=125;k>0;k--);
- }
- void main()
- {
- P1=0xff;
- while(1)
- {
- b=a>>1;
- if(a&0x01)
- {
- b=b|0x80;
- }
- a=b;
- P1=a;
- delay(255);
- delay(255);
- delay(255);
- }
- }
复制代码
|