当前位置:首页 > 行业资料 > 酒店餐饮 > 8x8x8LED光立方原理加程序
8x8x8LED光立方周渴望南阳理工学院Q418084696功能;通过自定义代码实现LED炫丽动画效果。通过按钮P3-7按钮实现动画与暂停。底面是512个LED分成64组的共阳极由8个74hc573控制,每层64个LED共阴极接在一起,共引出8跟负极与uln2803相连由其控制(这里注意uln280输出高电平LED负极通,低电平LED负极断)。原理:先点亮最下层LED,假设8个74hc573全输出高电平,uln2803控制最下层输出高电平,那么最下层64个LED都点亮,延时10ms到5ms,关断最下层显示开通第二层假设也是8个74hc573全输出高电平,那么倒数第二层64个LED全亮,再延时2ms到5ms那么以此类推每层的LED64个全都会亮,由于从第一层亮到最后一层亮时间小于50ms,由于人眼睛视觉暂留效果,就会觉得是全部层一起亮的,这样就“一起”点亮了512个LED。其实每层的LED亮的数量不一样就组成了各种画面,通过调节定时器,就会有一种绚丽的动画效果。本文使用的是STC12c5a60s2单片机,因为其程序存储空间大,stc89c52rc单片机完全可胜任(验证),只是程序太多要想办法了。原理图:本试验中P0口控制8个74hc573的锁存端,P1控制每层与uln2803相连,P2口传输到74hc573数据。本文使用动态扫苗,基于我之前做的16x16点阵文字移动显示程序,程序简单易懂,但是代码较多。程序:#includeAT89X52.HsbitLA0=P0^0;/*定义8个74hc573锁存脚*/sbitLA1=P0^1;sbitLA2=P0^2;sbitLA3=P0^3;sbitLA4=P0^4;sbitLA5=P0^5;sbitLA6=P0^6;sbitLA7=P0^7;sbitKEY=P3^7;/*定义暂停开关*/voidKEYKONG();/*按钮程序*/unsignedcharcodeceng[]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};/*8层控制代码每次亮一层*/unsignedcharcodedi[1224][8]={{0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},{0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},/*动画代码,纵向扫描*/{0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},{0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},{0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},{0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},{0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},{0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*31*/{0x00,0x00,0x00,0x00,0x38,0x38,0x38,0x38},{0x00,0x00,0x00,0x00,0x44,0x44,0x44,0x44},{0x00,0x00,0x00,0x00,0x04,0x04,0x04,0x04},{0x00,0x00,0x00,0x00,0x3c,0x3c,0x3c,0x3c},{0x00,0x00,0x00,0x00,0x04,0x04,0x04,0x04},{0x00,0x00,0x00,0x00,0x44,0x44,0x44,0x44},{0x00,0x00,0x00,0x00,0x38,0x38,0x38,0x38},{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*32*/{0x38,0x38,0x38,0x38,0x38,0x38,0x38,0x38},{0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44},{0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04},{0x3c,0x3c,0x3c,0x3c,0x3c,0x3c,0x3c,0x3c},{0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04},{0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44},{0x38,0x38,0x38,0x38,0x38,0x38,0x38,0x38},{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*33*/{0x38,0x38,0x38,0x38,0x00,0x00,0x00,0x00},{0x44,0x44,0x44,0x44,0x00,0x00,0x00,0x00},{0x04,0x04,0x04,0x04,0x00,0x00,0x00,0x00},{0x3c,0x3c,0x3c,0x3c,0x00,0x00,0x00,0x00},{0x04,0x04,0x04,0x04,0x00,0x00,0x00,0x00},{0x44,0x44,0x44,0x44,0x00,0x00,0x00,0x00},{0x38,0x38,0x38,0x38,0x00,0x00,0x00,0x00},{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*34*/{0x38,0x38,0x00,0x00,0x00,0x00,0x00,0x00},{0x44,0x44,0x00,0x00,0x00,0x00,0x00,0x00},{0x04,0x04,0x00,0x00,0x00,0x00,0x00,0x00},{0x3c,0x3c,0x00,0x00,0x00,0x00,0x00,0x00},{0x04,0x04,0x00,0x00,0x00,0x00,0x00,0x00},{0x44,0x44,0x00,0x00,0x00,0x00,0x00,0x00},{0x38,0x38,0x00,0x00,0x00,0x00,0x00,0x00},{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*34*/{0x38,0x38,0x00,0x00,0x00,0x00,0x00,0x00},{0x44,0x44,0x00,0x00,0x00,0x00,0x00,0x00},{0x04,0x04,0x00,0x00,0x00,0x00,0x00,0x00},{0x3c,0x3c,0x00,0x00,0x00,0x00,0x00,0x00},{0x04,0x04,0x00,0x00,0x00,0x00,0x00,0x00},{0x44,0x44,0x00,0x00,0x00,0x00,0x00,0x00},{0x38,0x38,0x00,0x00,0x00,0x00,0x00,0x00},{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*34*/{0x38,0x38,0x00,0x00,0x00,0x00,0x00,0x00},{0x44,0x44,0x00,0x00,0x00,0x00,0x00,0x00},{0x04,0x04,0x00,0x00,0x00,0x00,0x00,0x00},{0x3c,0x3c,0x00,0x00,0x00,0x00,0x00,0x00},{0x04,0x04,0x00,0x00,0x00,0x00,0x00,0x00},{0x44,0x44,0x00,0x00,0x00,0x00,0x00,0x00},{0x38,0x38,0x00,0x00,0x00,0x00,0x00,0x00},{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*34*/{0x38,0x38,0x00,0x00,0x00,0x00,0x00,0x00},{0x44,0x44,0x00,0x00,0x00,0x00,0x00,0x00},{0x04,0x04,0x00,0x00,0x00,0x00,0x00,0x00},{0x3c,0x3c,0x00,0x00,0x00,0x00,0x00,0x00},{0x04,0x04,0x00,0x00,0x00,0x00,0x00,0x00},{0x44,0x44,0x00,0x00,0x00,0x00,0x00,0x00},{0x38,0x38,0x00,0x00,0x00,0x00,0x00,0x00},{0x00,0x00,0x00,0x00,0x7c,0x7c,0x7c,0x7c},/*21*/{0x00,0x00,0x00,0x00,0x20,0x20,0x20,0x20},{0x00,0x00,0x00,0x00,0x10,0x10,0x10,0x10},{0x00,0x00,0x00,0x00,0x08,0x08,0x08,0x08},{0x00,0x00,0x00,0x00,0x04,0x04,0x04,0x04},{0x00,0x00,0x00,0x00,0x04,0x04,0x04,0x04},{0x00,0x00,0x00,0x00,0x44,0x44,0x44,0x44},{0x00,0x00,0x00,0x00,0x38,0x38,0x38,0x38},{0x7c,0x7c,0x7c,0x7c,0x7c,0x7c,0x7c,0x7c},/*22*/{0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20},{0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10},{0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08},{0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04},{0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04},{0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44},{0x38,0x38,0x38,0x38,0x38,0x38,0x38,0x38},{0x7c,0x7c,0x7c,0x7c,0x00,0x00,0x00,0x00},/*23*/{0x20,0x20,0x20,0x20,0x00,0x00,0x00,0x00},{0x10,0x10,0x10,0x10,0x00,0x00,0x00,0x00},{0x08,0x08,0x08,0x08,0x00,0x00,0x00,0x00},{0x04,0x04,0x04,0x04,0x00,0x00,0x00,0x00},{0x04,0x04,0x04,0x04,0x00,0x00,0x00,0x00},{0x44,0x44,0x44,0x44,0x00,0x00,0x00,0x00},{0x38,0x38,0x38,0x38,0x00,0x00,0x00,0x00},{0x7c,0x7c,0x00,0x00,0x00,0x00,0x00,0x00},/*24*/{0x20,0x20,0x00,0x00,0x00,0x00,0x00,0x00},{0x10,0x10,0x00,0x00,0x00,0x00,0x00,0x00},{0x08,0x08,0x00,0x00,0x00,0x00,0x00,0x00},{0x04,0x04,0x00,0x00,0x00,0x00,0x00,0x00},{0x04,0x04,0x00,0x00,0x00,0x00,0x00,0x00},{0x44,0x44,0x00,0x00,0x00,0x00,0x00,0x00},{0x38,0x38,0x00,0x00,0x
本文标题:8x8x8LED光立方原理加程序
链接地址:https://www.777doc.com/doc-6131110 .html