32LED心形灯程序源代码(包含仿真图)_第1页
32LED心形灯程序源代码(包含仿真图)_第2页
32LED心形灯程序源代码(包含仿真图)_第3页
32LED心形灯程序源代码(包含仿真图)_第4页
32LED心形灯程序源代码(包含仿真图)_第5页
已阅读5页,还剩11页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

#includeunsigned int m=1;void delayms(int n) /延时 inti;for(;n0;n-)for(i=330;i0;i-);void way1() /花样1:32个LED灯同时从灭到亮 int k;k=m+5;while(k)int i=5,j=5; for(;j0;j-)P0=0X00; P1=0X00;P2=0X00; P3=0X00;delayms(200); for(;i0;i-)P0=0Xff; P1=0Xff;P2=0Xff;P3=0Xff;delayms(200); k-; void way2() /花样2:交叉点亮,从右往左依次点亮,再依返回。 unsigned int k;unsigned char temp,temp1,sum=0; unsigned int i,j;k=m;while(k) for(j=2;j0;j-)P0=0X00;P1=0X00;P2=0X00; P3=0X00;/r-ldelayms(500);P0=0Xff; P1=0Xff;P2=0xff;P3=0xff; temp=0x01; for(i=0;i9;i+)P0=temp;delayms(70);temp=temp1; temp=0x01;for(i=0;i9;i+)P2=temp;delayms(70);temp=temp1;temp=0x01;for(i=0;i9;i+)P3=temp;delayms(70);temp=temp1; temp=0x01;for(i=0;i9;i+)P1=temp;delayms(70);temp=temprdelayms(500); P0=0Xff;P1=0Xff;P2=0xff;P3=0xff;temp=0x80;for(i=0;i1;temp=0x80;for(i=0;i1; temp=0x80;for(i=0;i1;temp=0x80; for(i=0;i1; P0=0X00;P1=0X00;P2=0X00; P3=0X00;delayms(500);P0=0Xff; P1=0Xff;P2=0xff;P3=0xff; temp=0x01;temp1=0x80; for(i=0;i9;i+)P0=temp;P1=temp1;temp=temp1;delayms(70); temp=0x01;temp1=0x80;for(i=0;i9;i+)P2=temp;P3=temp1;temp=temp1;delayms(70);temp=0x01;temp1=0x80;for(i=0;i9;i+)P3=temp;P2=temp1;temp=temp1;delayms(70); temp=0x01;temp1=0x80;for(i=0;i9;i+)P1=temp;P0=temp1;temp=temp1;delayms(70); k-; void way3() unsigned int i,sum,sum1,k,temp1; unsigned int temp=0x01; k=m; P0=0Xff; /两边同时向下闪P1=0Xff;P2=0xff;P3=0xff; while(k) temp1=0xfe;temp=0x7f;sum=0; for(i=0;i8;i+) P0=temp1;P1=temp;delayms(100); temp1=temp11; temp1=0xfe;temp=0x7f;sum=0; for(i=0;i8;i+) P2=temp1;P3=temp;delayms(100); temp1=temp11; P0=0X00; /全亮P1=0X00;P2=0x00;P3=0x00;delayms(100);temp=0x01; /返回temp1=0x80;sum=0;sum1=0; for(i=0;i8;i+) sum=sum+temp;P3=sum;temp=temp1;delayms(100); P2=0Xff; P3=0xff;delayms(100); temp=0x01;temp1=0x80;sum=0;sum1=0; for(i=0;i8;i+) sum=sum+temp;P1=sum;temp=temp1;delayms(100); P0=0Xff; /两边同时向上闪P1=0Xff;P2=0xff;P3=0xff; temp1=0xfe;temp=0x7f;sum=0; for(i=0;i8;i+) P3=temp1;P2=temp;delayms(100); temp1=temp11; temp1=0xfe;temp=0x7f;sum=0; for(i=0;i8;i+) P1=temp1;P0=temp;delayms(100); temp1=temp11; P0=0X00; /全亮P1=0X00;P2=0x00;P3=0x00;delayms(100);temp=0x01; /返回temp1=0x80;sum=0;sum1=0; for(i=0;i8;i+) sum=sum+temp;P0=sum;temp=temp1;delayms(100); temp=0x01;temp1=0x80;sum=0;sum1=0; for(i=0;i8;i+) sum=sum+temp;P2=sum;temp=temp1;delayms(100); k-; void way4() /相间交叉闪烁 unsigned int temp=0x55; unsigned int k,j;k=m+3;j=m+3;while(k)P0=temp;P1=temp;P2=temp;P3=temp;delayms(200);P0=temp;P1=temp;P2=temp;P3=temp;delayms(200); k-;while(j)P0=temp;P1=temp;P2=temp;P3=temp;delayms(200);P0=temp;P1=temp;P2=temp;P3=temp;delayms(200); j-; void way5() unsigned int k,j;/8个灯一起亮并旋转 k=m+4;j=m+4; while(k) P0=0xaa;delayms(200); P0=0xff; P0=0x55;delayms(200); P0=0xff; P2=0xaa;delayms(200); P2=0xff; P2=0x55;delayms(200); P2=0xff; P3=0xaa;delayms(200); P3=0xff; P3=0x55;delayms(200); P3=0xff; P1=0xaa;delayms(200); P1=0xff; P1=0x55;delayms(200); P1=0xff; k-; while(j) P1=0x55;delayms(200); P1=0xff; P1=0xaa;delayms(200); P1=0xff; P3=0x55;delayms(200); P3=0xff; P3=0xaa;delayms(200); P3=0xff; P2=0x55;delayms(200); P2=0xff; P2=0xaa;delayms(200); P2=0xff; P0=0x00;delayms(200); P0=0xff; P0=0xaa;delayms(200); P0=0xff; j-; void way6() /两边同时对称闪 unsigned int i,j,sum,sum1,k,temp1; k=m+1; while(k) P0=0Xff; P1=0Xff;P2=0xff;P3=0xff; for(j=3;j0;j-) temp1=0xfe; for(i=0;i8;i+) P0=temp1;P3=temp1;delayms(100); temp1=temp11; temp1=0xfe; for(i=0;i8;i+) P2=temp1;P1=temp1;delayms(100); temp1=temp10;j-) temp1=0x7f; /返回 for(i=0;i1;delayms(100); temp1=0x7f; for(i=0;i1;delayms(100); P0=0Xff; /全灭P1=0Xff;P2=0xff;P3=0xff;delayms(100); way3();for(j=3;j0;j-)temp1=0xfe; for(i=0;i8;i+) P0=temp1;P3=temp1;delayms(100); temp1=temp11; P0=0Xff; /全灭P1=0Xff;P2=0xff;P3=0Xff;delayms(100);temp1=0xfe; for(i=0;i8;i+) P2=temp1;P1=temp1;delayms(100); temp1=temp10;j-)temp1=0xfe; for(i=0;i8;i+) P0=temp1;P3=temp1;delayms(100); temp1=temp11; P0=0Xff; /全灭P1=0Xff;P2=0xff;P3=0Xff;delayms(100);temp1=0xfe; for(i=0;i8;i+) P2=temp1;P1=temp1;delayms(100); temp1=temp10;j-) temp1=0x7f; /返回 for(i=0;i1; P0=0Xff; /全灭P1=0Xff;P2=0xff;P3=0xff;delayms(100);temp1=0x7f; for(i=0;i1; P0=0Xff; /全灭P1=0Xff;P2=0xff;P3=0xff;delayms(100);k-; void way7() unsigned int temp,temp1,temp2,i,j;temp1=0xfe;for(j=0;j8;j+)temp=temp1;for(i=0;i8;i+) P0=temp; temp=temp1; delayms(100);P0=temp1;delayms(100);temp=temp1;for(i=0;i8;i+) P2=temp; temp=temp1; delayms(100);P2=temp1;delayms(100);temp=temp1;for(i=0;i8;i+) P3=temp; temp=temp1; delayms(100);P3=temp1;delayms(100);temp=temp1;for(i=0;i8;i+) P1=temp; temp=temp1; delayms(100);P1=temp1;delayms(100);temp1=temp11;delayms(100);P0=0Xff; /全灭P1=0Xff;P2=0xff;P3=0xff;delayms(100);temp2=0x7f;for(j=0;j8;j+)temp=temp2;for(i=0;i1; delayms(100);P1=temp2;delayms(100);temp=temp2;for(i=0;i1; delayms(100);P3=temp2;delayms(100);temp=temp2;for(i=0;i1;

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论