基于51单片机的心形流水灯.doc

上传人:仙人指路1688 文档编号:4137382 上传时间:2023-04-07 格式:DOC 页数:26 大小:18.36MB
返回 下载 相关 举报
基于51单片机的心形流水灯.doc_第1页
第1页 / 共26页
基于51单片机的心形流水灯.doc_第2页
第2页 / 共26页
基于51单片机的心形流水灯.doc_第3页
第3页 / 共26页
基于51单片机的心形流水灯.doc_第4页
第4页 / 共26页
基于51单片机的心形流水灯.doc_第5页
第5页 / 共26页
点击查看更多>>
资源描述

《基于51单片机的心形流水灯.doc》由会员分享,可在线阅读,更多相关《基于51单片机的心形流水灯.doc(26页珍藏版)》请在三一办公上搜索。

1、 基于51单片机的心形流水灯视频地址新手焊接、技术有限。振荡电路藏于单片机下。30个led灯并联未加电阻。供电采用移动电源内置的锂电池从生日蜡烛上拆下来的电路。共用一个开关。附源程序:C语言#includeunsigned int x,y;void delayms(unsigned int z) /延时程序 unsigned int i,j; for(i=z;i0;i-) for(j=110;j0;j-);/*-*/ void Offall() /开启所有灯 P0=0x00; P1=0x00; P2=0x00; P3=0x00;/*-*/void Onall()/关闭所有灯 P0=0xff;

2、P1=0xff; P2=0xff; P3=0xff;/*-*/void ls()/等时流水灯 P0=0x00; P0=0x01; delayms(50); P0=0x02; delayms(50); P0=0x04; delayms(50) ; P0=0x08; delayms(50) ; P0=0x10; delayms(50) ; P0=0x20; delayms(50); P0=0x40; delayms(50) ; P0=0x80; delayms(50); P0=0x00; P2=0x00; P2=0x80; delayms(50) ; P2=0x40; delayms(50); P

3、2=0x20; delayms(50) ; P2=0x10; delayms(50) ; P2=0x08; delayms(50) ; P2=0x04; delayms(50); P2=0x02; delayms(50) ; P2=0x01; delayms(50); P2=0x00; P3=0x00; P3=0x80; delayms(50) ; P3=0x40; delayms(50); P3=0x20; delayms(50) ; P3=0x10; delayms(50) ; P3=0x08; delayms(50) ; P3=0x04; delayms(50); P3=0x02; de

4、layms(50) ; P3=0x01; delayms(50); P3=0x00; P1=0x00; P1=0x80; delayms(50) ; P1=0x40; delayms(50); P1=0x20; delayms(50) ; P1=0x10; delayms(50) ; P1=0x08; delayms(50) ; P1=0x04; delayms(50); P1=0x02; delayms(50) ; P1=0x01; delayms(50); P1=0x00; P0=0x01; delayms(50); P0=0x00;/*-*/void fxls()/反向等时流水灯 P0=

5、0x00; P0=0x01; delayms(50); P0=0x00; P1=0x00; P1=0x01;delayms(50); P1=0x02;delayms(50); P1=0x04;delayms(50); P1=0x08;delayms(50); P1=0x10;delayms(50); P1=0x20;delayms(50); P1=0x40;delayms(50); P1=0x80;delayms(50);P1=0x00; P3=0x00; P3=0x01;delayms(50); P3=0x02;delayms(50); P3=0x04;delayms(50); P3=0x0

6、8;delayms(50); P3=0x10;delayms(50); P3=0x20;delayms(50); P3=0x40;delayms(50); P3=0x80;delayms(50);P3=0x00; P2=0x00; P2=0x01;delayms(50); P2=0x02;delayms(50); P2=0x04;delayms(50); P2=0x08;delayms(50); P2=0x10;delayms(50); P2=0x20;delayms(50); P2=0x40;delayms(50); P2=0x80;delayms(50);P2=0x00; P0=0x00;

7、 P0=0x80;delayms(50); P0=0x40;delayms(50); P0=0x20;delayms(50); P0=0x10;delayms(50); P0=0x08;delayms(50); P0=0x04;delayms(50); P0=0x02;delayms(50); P0=0x01;delayms(50);P0=0x00; /*-*/void bsb()/半双边流水 由上至下 Offall(); P0=0x01;delayms(50); P0=0x02;P1=0x01;delayms(50); P0=0x04;P1=0x02;delayms(50); P0=0x08

8、;P1=0x04;delayms(50); P0=0x10;P1=0x08;delayms(50); P0=0x20;P1=0x10;delayms(50); P0=0x40;P1=0x20;delayms(50); P0=0x80;P1=0x40;delayms(50);P0=0x00; P2=0x80;P1=0x80;delayms(50);P1=0x00; P2=0x40;P3=0x01;delayms(50); P2=0x20;P3=0x02;delayms(50); P2=0x10;P3=0x04;delayms(50); P2=0x08;P3=0x08;delayms(50); P

9、2=0x04;P3=0x10;delayms(50); P2=0x02;P3=0x20;delayms(50); P2=0x01;P3=0x40;delayms(50);Offall(); P3=0x80;delayms(50);Offall(); /*-*/void fbsb() /半双边流水 由下至上 Offall(); P3=0x80;delayms(50); P2=0x01;P3=0x40;delayms(50); P2=0x02;P3=0x20;delayms(50); P2=0x04;P3=0x10;delayms(50);P2=0x08;P3=0x08;delayms(50);P

10、2=0x10;P3=0x04;delayms(50);P2=0x20;P3=0x02;delayms(50);P2=0x40;P3=0x01;delayms(50);Offall();P2=0x80;P1=80;delayms(50);Offall();P0=0x80;P1=0x40;delayms(50);P0=0x40;P1=0x20;delayms(50);P0=0x20;P1=0x10;delayms(50);P0=0x10;P1=0x08;delayms(50);P0=0x08;P1=0x04;delayms(50);P0=0x04;P1=0x02;delayms(50);P0=0x

11、02;P1=0x01;delayms(50);Offall();P0=0x01;Offall();void zxsz() /正向生长 Offall();P0=0x01;delayms(50);P0=0x03;delayms(50);P0=0x07;delayms(50);P0=0x0f;delayms(50);P0=0x1f;delayms(50);P0=0x3f;delayms(50);P0=0x7f;delayms(50);P0=0xff;delayms(50);P2=0x80;delayms(50);P2=0xc0;delayms(50);P2=0xe0;delayms(50);P2=0

12、xf0;delayms(50);P2=0xf8;delayms(50);P2=0xfc;delayms(50);P2=0xfe;delayms(50);P2=0xff;delayms(50);P3=0x80;delayms(50);P3=0xc0;delayms(50);P3=0xe0;delayms(50);P3=0xf0;delayms(50);P3=0xf8;delayms(50);P3=0xfc;delayms(50);P3=0xfe;delayms(50);P3=0xff;delayms(50);P1=0x80;delayms(50);P1=0xc0;delayms(50);P1=0

13、xe0;delayms(50);P1=0xf0;delayms(50);P1=0xf8;delayms(50);P1=0xfc;delayms(50);P1=0xfe;delayms(50);P1=0xff;delayms(50);/*-*/void fxsz() /反向生长 Offall();P0=0x01;delayms(50);P1=0x01;delayms(50);P1=0x03;delayms(50);P1=0x07;delayms(50);P1=0x0f;delayms(50);P1=0x1f;delayms(50);P1=0x3f;delayms(50);P1=0x7f;dela

14、yms(50);P1=0xff;delayms(50);P3=0x01;delayms(50);P3=0x03;delayms(50);P3=0x07;delayms(50);P3=0x0f;delayms(50);P3=0x1f;delayms(50);P3=0x3f;delayms(50);P3=0x7f;delayms(50);P3=0xff;delayms(50);P2=0x01;delayms(50);P2=0x03;delayms(50);P2=0x07;delayms(50);P2=0x0f;delayms(50);P2=0x1f;delayms(50);P2=0x3f;dela

15、yms(50);P2=0x7f;delayms(50);P2=0xff;delayms(50);P0=0x81;delayms(50);P0=0xc1;delayms(50);P0=0xe1;delayms(50);P0=0xf1;delayms(50);P0=0xf9;delayms(50);P0=0xfd;delayms(50);P0=0xff;delayms(50);/*-*/void zxsw() /正向死亡 Onall();P0=0xfd;delayms(50);P0=0xf9;delayms(50);P0=0xf1;delayms(50);P0=0xf0;delayms(50);P

16、0=0xe1;delayms(50);P0=0xc1;delayms(50);P0=0x81;delayms(50);P0=0x01;delayms(50);P2=0x7f;delayms(50);P2=0x3f;delayms(50);P2=0x1f;delayms(50);P2=0x0f;delayms(50);P2=0x07;delayms(50);P2=0x03;delayms(50);P2=0x01;delayms(50);P2=0x00;delayms(50);P3=0x7f;delayms(50);P3=0x3f;delayms(50);P3=0x1f;delayms(50);P

17、3=0x0f;delayms(50);P3=0x07;delayms(50);P3=0x03;delayms(50);P3=0x01;delayms(50);P3=0x00;delayms(50);P1=0x7f;delayms(50);P1=0x3f;delayms(50);P1=0x1f;delayms(50);P1=0x0f;delayms(50);P1=0x07;delayms(50);P1=0x03;delayms(50);P1=0x01;delayms(50);P1=0x00;delayms(50);P0=0x00;delayms(50);/*-*/void fxsw() /反向死

18、亡 Onall();P1=0xfe;delayms(50);P1=0xfc;delayms(50);P1=0xf8;delayms(50);P1=0xf0;delayms(50);P1=0xe0;delayms(50); P1=0xc0;delayms(50);P1=0x80;delayms(50);P1=0x00;delayms(50);P3=0xfe;delayms(50);P3=0xfc;delayms(50);P3=0xf8;delayms(50);P3=0xf0;delayms(50);P3=0xe0;delayms(50);P3=0xc0;delayms(50);P3=0x80;d

19、elayms(50);P3=0x00;delayms(50);P2=0xfe;delayms(50);P2=0xfc;delayms(50);P2=0xf8;delayms(50);P2=0xf0;delayms(50);P2=0xe0;delayms(50);P2=0xc0;delayms(50);P2=0x80;delayms(50);P2=0x00;delayms(50);P0=0x7f;delayms(50);P0=0x3f;delayms(50);P0=0x1f;delayms(50);P0=0x0f;delayms(50);P0=0x07;delayms(50);P0=0x03;d

20、elayms(50);P0=0x01;delayms(50);P0=0x00;delayms(50); /*-*/void bbs()/半边交替闪 Offall();P0=0x00;P2=0xff;P3=0x80;delayms(200);Offall();P0=0xfe;P1=0xff;P3=0xff;delayms(200);/*-*/void sxs()/上下交替闪Offall();P1=0xff;P0=0x00;P2=0x80;delayms(200);Offall();P2=0x7f;P3=0xff;delayms(200);void cx() /出现一点点Offall();dela

21、yms(1000);P0=0x00;P2=0x00;P1=0x40;P3=0x00;delayms(1000);P0=0x20;P2=0x40;P1=0x40;P3=0x00;delayms(1000);P0=0x24;P2=0x42;P1=0x40;P3=0x04;delayms(1000);P0=0xa6;P2=0x5a;P1=0x52;P3=0x65;delayms(1000);P0=0xee;P2=0xdf;P1=0xdb;P3=0xef; delayms(1000);P0=0xff;P2=0xff;P1=0xff;P3=0xff;delayms(1000); void xs() /一

22、点点消失Onall();delayms(1000);P0=0xee;P2=0xdf;P1=0xdb;P3=0xef; delayms(1000);P0=0xa6;P2=0x5a;P1=0x52;P3=0x65;delayms(1000);P0=0x24;P2=0x42;P1=0x40;P3=0x04;delayms(1000);P0=0x20;P2=0x40;P1=0x40;P3=0x00;delayms(1000);P0=0x00;P2=0x00;P1=0x40;P3=0x00;delayms(1000);Offall();delayms(1000);void main()Onall();delayms(1000);Offall();delayms(1000); cx();/一点点出现xs();zxsw();/* 正向死亡*/ls(); /* 正向流水 */zxsz();/* 正向生长 */zxsw(); /* 正向死亡 */fxsz();/* 反向生长 */fxsw(); /* 反向死亡 */fxls(); /* 反向流水*/bsb(); /* 半双边流水由上至下 */fbsb();/* 半双边流水 由下至上 */sxs();bbs(); 版权所有:山东科技大学 信息与电气工程学院 电气信息类2012级14班 ssk

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 办公文档 > 其他范文


备案号:宁ICP备20000045号-2

经营许可证:宁B2-20210002

宁公网安备 64010402000987号