单片机C语言程序设计:花样流水灯

-回复 -浏览
楼主 2020-05-20 06:28:33
举报 只看此人 收藏本贴 楼主

名称:花样流水灯

说明:16 只 LED 分两组

按预设的多种花样变换显示

*/

#include<reg51.h>

#define uchar unsigned char

#define uint unsigned int

uchar code Pattern_P0[]=

{

0xfc,0xf9,0xf3,0xe7,0xcf,0x9f,0x3f,0x7f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,

 0xe7,0xdb,0xbd,0x7e,0xbd,0xdb,0xe7,0xff,0xe7,0xc3,0x81,0x00,0x81,0xc3,0xe7,0xff,

 0xaa,0x55,0x18,0xff,0xf0,0x0f,0x00,0xff,0xf8,0xf1,0xe3,0xc7,0x8f,0x1f,0x3f,0x7f,

 0x7f,0x3f,0x1f,0x8f,0xc7,0xe3,0xf1,0xf8,0xff,0x00,0x00,0xff,0xff,0x0f,0xf0,0xff,

 0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,

 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe,

 0xfe,0xfc,0xf8,0xf0,0xe0,0xc0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xc0,0xe0,0xf0,0xf8,0xfc,0xfe,

 0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff 

};

uchar code Pattern_P2[]=

{

 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfe,0xfc,0xf9,0xf3,0xe7,0xcf,0x9f,0x3f,0xff,

 0xe7,0xdb,0xbd,0x7e,0xbd,0xdb,0xe7,0xff,0xe7,0xc3,0x81,0x00,0x81,0xc3,0xe7,0xff,

 0xaa,0x55,0x18,0xff,0xf0,0x0f,0x00,0xff,0xf8,0xf1,0xe3,0xc7,0x8f,0x1f,0x3f,0x7f,

 0x7f,0x3f,0x1f,0x8f,0xc7,0xe3,0xf1,0xf8,0xff,0x00,0x00,0xff,0xff,0x0f,0xf0,0xff,

 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f,

 0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,

 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfe,0xfc,0xf8,0xf0,0xe0,0xc0,0x80,0x00,

 0x00,0x80,0xc0,0xe0,0xf0,0xf8,0xfc,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,

 0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff 

};

//延时

void DelayMS(uint x)

{

uchar i;

while(x--)

{

for(i=0;i<120;i++);

}

}

//主程序

void main()

{

uchar i;

while(1)

{ //从数组中读取数据送至 P0 和 P2 口显示

for(i=0;i<136;i++)

P0=Pattern_P0[i];

P2=Pattern_P2[i];

DelayMS(100); 

}

}

本文转自网络,版权归原作者,如果您觉得不好,请联系我们删除!

广告

关于立创商城

立创商城(WWW.SZLCSC.COM)成立于2011年,致力于为客户提供一站式电子元器件线上采购服务,成交量全国领先。拥有10000多平方米现代化元器件仓库,现货库存超100000种,集团电子全产业链自营服务涵盖:在线EDA(LCEDA)+行业领先的PCB打样/中小批量+元器件商城+钢网制造+SMT贴片+电子设计教育及方案。作为一家品种齐全、自营库存、质量有保障的电子元器件垂直商城,立创商城所有元器件均从原厂或代理商正规渠道采购,保证原装正品,为您提供专业的一站式元器件采购服务。

我要推荐
转发到