您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 经营企划 > 444光立方电路图及程序
3.1单片机资源分配情况将4*4*4的LED光立方分层4层,分别由单片机的P1.0,P1.1,P1.2,P1.3,四个口来控制每一层,且给低电平有效,再有P0口和P1的总共16个口来控制16列,给高电平有效,P0和P1口加上位排阻,再给每一列加三极管放大,三极管的基极接单片机的P0和P1口,集电极接5V电源,发射极接每一列。这样就可以通过控制每个口的输出信号来控制每个的亮灭。3.2复位电路通过某种方式,是单片机内部各类寄存器的值变为出事状态的操作称为复位。单片机的复位是通过外部电路来实现的,复位引脚RET通过一个施密特触发器与复位电路相连接,施密特触发器用作噪声抑制,伟哥机器周期的S5P2时刻,复位电路采样一次施密特输出电平,获得内部复位操作所需要的信号。单片机的时钟电路正常工作后,CPU在RET/VPD引脚上连续采集到两个机器周期的高电平后就可以完成复位操作了,但实际应用时,复位电平的脉冲宽度一般大于1ms。复位电路通常采用上电复位、手动按键复位和看门狗复位三种方式,本次采用的是上电复位方式。3.3时钟电路单片机的各个功能部件的运行都是是时钟控制信号为基准,一拍一拍的工作。因此时钟频率直接影响单片机的速度,时钟电路的质量也直接影响单片机2系统的可靠性和稳定性。常用的时钟电路设计为内部时钟方式,单片机内部有一个由反向放大器构成的震荡电路,芯片上的XTAL1和XTAL2分别为震荡电路的输入和输出端。只要在这两个引脚上接一个石英晶体振荡器和两个微调电容就构成内部方式的振荡器电路,有振荡器产生自激振荡,便构成一个完整的震荡信号发生器。一般选用石英晶体振荡器。此电路在加电大约延迟10ms后振荡器起振,在XTAL2引脚产生幅度为3V左右的正弦波时钟信号,其振荡频率主要由石英晶振的频率确定。电路中两个电容C1、C2的作用有两个:一是帮助振荡器起振;二是对振荡器的频率进行微调。本系统的C1、C2的值为33pf。单片机在工作时,有内部振荡器产生或由外直接输入的送至内部控制逻辑单元的时钟信号的周期称为时钟周期。其大小是时钟信号频率的倒数,f表示。图2中的时钟频率为12MHz,即f=12MHz,则时钟周期为1/12us。附注:三极管可以不接,只是会影响光源亮度。3.4系统的工作原理图光立方一、二层:3光立方三、四层:单片机口点连接:4三极管放大电路:5总原理图:63.5焊接实物图7元器件清单:名称数量大LED灯70个AT89S521片按键1901316个102排阻2个1K电阻16个20pF瓷片电容2个12MHz晶振1个10uF电容1个330电阻1个4.7K电阻1个3.3C语言程序#includereg51.h#defineucharunsignedcharvoiddelay100ms(uchardata1ms){uchari,j,m;for(i=0;idata1ms;i++)for(j=0;j110;j++)for(m=0;m100;m++);}voiddisp(ucharceng,ucharlie1,ucharlie2){8delay100ms(7);P1=ceng;P2=lie1;P0=lie2;}voidmain(void){unsignedcharhang,shu1;unsignedcharcodeC1[][16]={{0x07,0x0B,0x0D,0x0E,0x0E,0x0C,0x08,0x00,0x00,0x08,0x0C,0x0E,0x0C,0x08,0x00,0x00},{0x08,0x0C,0x0E,0x0C,0x08,0x00,0x00,0x08,0x0C,0x0E,0x0C,0x08,0x00,0x00,0x08,0x0C},{0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E},{0x0C,0x08,0x00,0x00,0x08,0x0C,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x0C,0x0E,0x0F,0x0E,0x0C,0x08,0x00},{0x00,0x00,0x00,0x00,0x00,0x0D,0x0D,0x0D,0x05,0x09,0x09,0x09,0x0D,0x0D,0x09D,0x05},{0x09,0x09,0x09,0x00,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09},{0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09}};unsignedcharcodeL1[][16]={{0xFF,0xFF,0xFF,0xFF,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x96,0x96,0x96,0x96,0x96},{0x96,0x96,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC},{0x01,0x03,0x07,0x0F,0x8E,0x8C,0x88,0x80,0x00,0x00,0x00,0x10,0x30,0x70,0x70,0x60},{0x60,0x60,0x60,0x60,0x60,0x60,0x60,0xCC,0x0F,0x33,0x66,0xCC,0xF0,0x33,0x66,0xCC},{0x66,0x33,0xF0,0xCC,0x66,0x33,0xF0,0xCC,0xCC,0xCC,0xCC,0xCC,0x60,0x60,0x60,0x60},{0xE8,0x74,0x32,0x11,0x00,0x06,0x66,0x60,0x60,0x60,0x00,0x00,0x06,0x66,0x60,0x60},{0x60,0x00,0x00,0x00,0x80,0x40,0x20,0x20,0x20,0x60,0x62,0x60,0x30,0x10,0x80,0xC0},{0x60,0x60,0x60,0x60,0x64,0x60,0x30,0x10}//10{0x01,0x02,0x04,0x08,0x80,0x40,0x20,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},//列扫描};unsignedcharcodeL2[][16]={{0xFF,0xFF,0xFF,0xFF,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x69,0x69,0x69,0x69,0x69},{0x69,0x69,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0x33,0x33,0x33,0x33,0x33,0x33,0x33},{0x00,0x00,0x00,0x00,0x00,0x08,0x88,0xC8,0xE8,0xF0,0x71,0x31,0x11,0x10,0x04,0x06},{0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x33,0xF0,0xCC,0x66,0x33,0x0F,0xCC,0x66,0x33},{0x66,0xCC,0x0F,0x33,0x66,0xCC,0x0F,0x33,0x33,0x33,0x33,0x33,0x06,0x06,0x06,0x06},{0x8E,0x47,0x23,0x11,0x00,0x00,0x00,0x06,0x06,0x06,0x66,0x60,0x00,0x00,0x06,0x06},{0x06,0x66,0x60,0x00,0x08,0x0C,0x06,0x66,0x06,0x06,0x06,0x06,0x03,0x01,0x00,0x08},{0x04,0x64,0x06,0x06,0x06,0x06,0x03,0x01}//{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x02,0x04,0x08,0x80,0x40,0x20,0x10}11};while(1){for(hang=0;hang8;hang++){for(shu1=0;shu116;shu1++)disp(C1[hang][shu1],L1[hang][shu1],L2[hang][shu1]);}//for(hang=0;hang1;hang++)//{//for(shu1=0;shu116;shu1++)//{shu2=0;//disp(C1[shu2][shu2],L1[hang][shu1],L2[hang][shu1]);//}//}}}
本文标题:444光立方电路图及程序
链接地址:https://www.777doc.com/doc-4921736 .html