您的位置 首页 传感器

AT89C51单片机的流水灯操控规划

AT89C51单片机的流水灯控制设计-由于程序花样显示比较复杂,所以完全可以通过查表得方式编写程序,简单。如果想显示不同的花样,只需要改写表中的数据即可。

  因为程序把戏显现比较复杂,所以完全可以经过查表得方法编写程序,简略。假如想显现不同的把戏,只需要改写表中的数据即可。流水灯程序:#include “reg51.h”

AT89C51单片机的流水灯操控规划

  #define uint unsigned int

  #define uchar unsigned char

  const table[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};

  void delay(uint z) //delay 1ms

  {

  uint x,y;

  for(x=z;x》0;x–)

  for(y=124;y》0;y–);

  }void main(void)

  {

  uchar x;

  while(1)

  {

  for(x=0;x《8;x++)

  {

  P0=table[x];

  delay(1000);

  }

  }

  }把戏灯程序:#include “reg51.h”

  #define uint unsigned int

  #define uchar unsigned char

  const table[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f, //正向流水灯

  0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe,0xff, //反向流水灯

  0xaa,0x55,0xaa,0x55,0xaa,0x55,0xff, //隔灯闪耀

  0xf0,0x0f,0xf0,0x0f,0xff, //高四盏闪耀,低四盏闪耀

  0x33,0xcc,0x33,0xcc,0x33,0xcc,0xff}; //隔两盏闪耀

  void delay(uint z) //delay 1ms

  {

  uint x,y;

  for(x=z;x》0;x–)

  for(y=124;y》0;y–);

  }void main(void)

  {

  uchar x;

  while(1)

  {

  for(x=0;x《35;x++)

  {

  P0=table[x];

  delay(1000);

  }

  }

  }
来历;21ic

声明:本文内容来自网络转载或用户投稿,文章版权归原作者和原出处所有。文中观点,不代表本站立场。若有侵权请联系本站删除(kf@86ic.com)https://www.86ic.net/yingyong/chuanganqi/343923.html

为您推荐

联系我们

联系我们

在线咨询: QQ交谈

邮箱: kf@86ic.com

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

返回顶部