51单片机常见的五种流水灯编写方式.docVIP

  • 18
  • 0
  • 约1.11千字
  • 约 3页
  • 2018-10-09 发布于河北
  • 举报
51单片机常见的五种流水灯编写方式

51单片机常见的五种流水灯编写方式 通过改变赋值实现流水灯 void main() { while(1) { P2=0xfe; delay1ms(500); P2=0xfd; delay1ms(500); P2=0xfb; delay1ms(500); P2=0xf7; delay1ms(500); P2=0xef; delay1ms(500); P2=0xdf; delay1ms(500); P2=0xbf; delay1ms(500); P2=0x7f; delay1ms(500); } } 通过公式运算实现流水灯 void main() { while(1) { uint a,b=1; P2=0xfe; delayms(500); for(a=0;a7;a++) { P2-=b; // P2=P2-b delayms(500); b=b*2; //都化为同一类型进制运算 } } } 通过操作符与“|”实现流水灯 (通过移位实现流水灯) void main() { uc

文档评论(0)

1亿VIP精品文档

相关文档