单片机手工艺术品流水灯简介.docx

单片机手工艺术品流水灯简介

单片机综合课程设计 题 目: LED流水灯的设计 班 级: 0312407 姓 名: 石设宇 赵政德 张永乐 学 号: 031240732 031240734 031240729 一、设计内容与目标 此设计主要是采用控制系统的延时来完成的,此设计中是将32个LED 变换多种姿势显示,且包含九种模式,每种模式中流水灯样式和数码管显示一一对应,每次对P0、P1、P2、P3口赋予相应的值,即可达到预期的效果,再和不同的延时相配合,就能达到不同的流水效果了。 二、硬件电路设计 程序设计 四、Proteus仿真原理图与实物照片 五、实验结果与分析 实验实现了将32个LED 变换多种姿势显示,包含九种模式,每种模式中流水灯样式和数码管显示一一对应,每次对P0、P1、P2、P3口赋予相应的值可达到了预期的效果,和不同的延时相配合,达到了不同的流水效果了。本实验成功。 六、程序详细清单 #includereg52.h #include intrins.h #define uint unsigned int #define uchar unsigned char //延时 void delay(uint k) { uint i,j; for(i=k;i--;i0) for(j=100;j--;j0); } void main() { uchar temp0,temp1; uchar yi; uchar yi0,yi1; uint i,j,k,a,b; j=k=a=b=3; //全部亮 P0=P1=P2=P3=0x00; delay(700); P0=P1=P2=P3=0xff; //每个io口独自亮 for(i=2;i--;i0) { P1=P0=0x00; delay(500); P1=P0=0xff; P3=P2=0x00; delay(500); P3=P2=0xff; } //全部亮,闪三次 for(i=2;i--;i0) { P0=P1=P2=P3=0x00; delay(100); P0=P1=P2=P3=0xff; delay(100); } //P1、P2亮,P3、P0暗 for(i=3;i--;i0) { P1=0x00,P2=0x00; P3=0xff,P0=0xff; delay(500); P1=0xff,P2=0xff,P3=0x00,P0=0x00; delay(500); } //四个点的流水 while(j0) { temp0=0xfe,temp1=0x7f; P1=P3=temp0,P2=P0=temp1; delay(100); for(i=7;i--;i0) { temp0=_crol_(temp0,1),temp1=_cror_(temp1,1); P1=P3=temp0,P2=P0=temp1; delay(100); } j--; } //全部亮,闪三次 for(i=3;i--;i0) { P0=P1=P2=P3=0x00; delay(300); P0=P1=P2=P3=0xff; delay(300); } //四个IO口同样跟踪流水 while(k0) { temp0=0xfe,temp1=0x7f; P1=P3=temp0,P2=P0=temp1; delay(60); for(i=7;i--;i0) { temp0=temp01,temp1=temp11; P1=P3=temp0,P2=P0=temp1; delay(60); } k--; } P0=P1=P3=P2=0xff; while(k3) { temp0=0x7f,temp1=0xfe; P1=P3=temp0,P2=P0=temp1; delay(60); for(i=7;i--;i0) { temp0=temp01,temp1=temp11; P1=P3=temp0,P2=P0=temp1; delay(60)

文档评论(0)

1亿VIP精品文档

相关文档