《LED摇摇棒的详细制作资料.docx》由会员分享,可在线阅读,更多相关《LED摇摇棒的详细制作资料.docx(7页珍藏版)》请在优知文库上搜索。
1、1.ED摇摇棒的具体制作资料1.ED摇摇棒的制作大家知道,人的眼睛存在视觉暂留现象,正因为眼睛的反应迟钝,才丰富r人的视觉感受。1.ED摇摇棒很好地利用了人眼的视觉暂留特性。下图是基于51单片机限制、16只高亮度1.ED发光:极管构成的摇摇棒,协作手的左右摇挖就可呈现一幅完整的画面,可以显示字符、图片等。演示效果见自制1.ED摇摇棒展示【图】。黑暗条件下拍摄的效果图片:实物外形图:基本原理与硬件电路设计:16只1.ED发光管作为画面每列的显示,左右摇攫起到了扫描的作用,人眼的视觉暂留现象使得看到的是一幅完整的画面。与1.ED点阵的显示有几分相仿。硬件电路如下图(点击可放大)。系统电源VCC为5
2、V,卜载程序和调试时肯定要保证5V电压,实际运用时用3节干电池串联4.5V即可。T89S52单片机作为限制器,在它的PO、P2口接有16只以共阳的方式连接的高亮度1.ED,由单片机输出低电平点亮。PO口的上拉电阻RAl不能少。串在1.ED公共端的二极管Dl会产生肯定的压降,用来爱护1.ED,经实测1.ED点亮时两端电压为3V左右,在1.ED的平安承受范围内。Kl是画面切换开关,用于切换显示不同内容:Sl为水银开关。水银开关的作用:棒在摇动时,只能在朝某一方向摇动时显示,否则会出现镜像字或镜像画面,所以通过接一只水银开关来限制,使摇摇棒从左向右摇动时将内容显示出来。硬件制作:运用的是直径5mm的
3、红色高亮1.ED,感觉太大了些,远看效果很好但近看时字不够连贯。建议运用直径为3mm的高亮1.ED,颜色可依据个人喜好选择。水银开关里的水银珠很活跃,导致在接通时简单产生抖动,所以将水银开关斜向上放置(尖尖朝斜上方45角),靠水银珠自身重力的作用削减抖动:IC座里面隐藏元件,既美观乂能爱护元件:软件设计:/*程序名称:1.ED摇摇棒显示64*16像素简要说明:外部中断方式INTO显示:取模方式:纵向取模、字节倒序编写:龙崎幻影最终更新:09/11/15晚*/includeT89X52.hSdefineucharunsignedcharWdefineuintunsignedini宏定义sbitK
4、EY=P3_0定义画面切换按键ucharKY:KY作用在后面说明uchardisp;显示汉字指针ucharpic=0,num=0;/pic为按键次数;num为中断次数ucharcodelove=0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,Ox00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,OxFE,0x3F,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x0
5、0,0x00,0x00,0x00,0x00,0x00,0xF8,OxOF,0x04,0x10,0x02,0x20,0x02,0x20,0x02,0x20,0x02,0x20,0x04,0x10,OxF8,OxOF,0x00,0x00,0x00,0x00,0x00,0x00,OxFE,0x07,0x00,0x08,0x00,0x10,0x00,0x20,0x00,0x20,0x00,0x10,0x00,0x08,OxFE,0x07,0x00,0x00,0x00,0x00,0x00,0x00,OxFE,0x3F,0x82,0x20,0x82,0x20,0x82,0x20,0x82,0x20,0x8
6、2,0x20,0x82,0x20,0x82,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*1.OVE*/;ucharcodeloveyou=0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,Ox00,0x00,0x00,OxOOl0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0
7、x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,OxOOl0x78,0x00,OxFC,0x00,OxFE,0x01,OxFE,0x03,OxFE,0x07,OxFE,OxOF,OxFE,OxlF,OxFC,0x3F,0xF8,0x7F,OxFC,0x3F,OxFE,OxlF,OxFE1OxOF,OxFE,0x07,OxFE,0x03,OxFE,OxOltOxFC,0x00,0x78,0x00,0x00,0x00,0x00,0x00,0x00,0
8、x00,0x00,0x00,0x00,OxOO,0x00,0x00,0x00,OxOOl0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,OxOO,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,OxOO,0x00,0x00,0x00,0x00,*心形图案*/;ucharcodehehe=0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,Ox00,0x00,0x00,0x00
9、,0x00,0x00,0x00,0x00,0x00,0x00,0x00,OxCO10x01,0x40,0x01,OxCO,0x01,0x00,0x00,0x00,0x00,OxFO,OxOF,0x08,0x10,0x04,0x20,0x00,0x00,0x00,0x00,OxFO,03F,0x08,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x08,0x00,OxFO10x3F,0x00,0x00,0x00,OxOO,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,OxOO10x20,0x00,0x00,0x00,0x00,OxFO,
10、0x3F,0x08,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x08,OxOO,OxFO,0x3F,0x00,0x00,0x00,OxOO,0x04,0x20,0x08,0x10,OxFO,OxOF,0x00,0x00,0x00,0x00,OxCO10x01,0x40,0x01,OxCO,OxOl,0x00,OxOOl0x00,OxOOl0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,OxOO,0x00,0x00,0x00,0x00,/*呵呵o(Jo图案*/;:/*函数声明*/voiddisplay!(
11、void);voiddisplay2(void);voiddisplay3(void):voiddisplay4(void);*n(us)延时子程序*/VoidDelayUS(UintN)uintx;for(x=0;x=N;x+);/*中断服务程序*/voidintersvr0(void)interrupt0using1KY=KY;每个摇动来回水银开关会在摆幅两端分别产生下降沿中断,只提取其中一次(从左向右摇才显示)if(KY=O)num+;计算中断次数switch(pic)选择画面case0:displayl();break;case1:display2();break;case2:disp
12、lay3();break;case3:display4();break;default:displayl();/*显示子程序1(汉字)*/voiddisplayl(void)uchari:if(num10)(disp+jnum=0;)/12个汉字分为3次显示完(每次显示4个),每中断10次切换if(disp2)disp=0;DeIayUs(5200);此处延时时间依各硬件差别而各不相同,试着调整使得显示内容居中即可for(i=0;i64:i+)P0=hanzidisp*128+i*2;P2=hanzidisp*128+i*2+l;DelayUs(100):/*显示子程序2(1.OVE)*/vo
13、iddisplay2(void)uchari:DelayUs(4000);for(i=0:i64;i+)P0=lovei*2:P2=lovei*2+1;DclayUs(120);/*显示子程序3(心形图案)*/voidclisplay3(void)uchari;DcIayUs(4000);for(i=0;i64;i+)P0=loveyoui*2;P2=Ioveyoui*2+l:DelayUs(120);/*显示子程序4(呵呵O(_)O图案)*/voiddisplay4(void)uchari;DelayUs(4000);for(i=0:i64:i+)P0=hehei*2;P2=hehei*2+
14、1;DelayUs(120);/*主函数*/voidmain(void)ITO=I;EXO=1;E=1;开中断,下降沿中断KY=O;While主程序中只检测按键If(KEY=O)画面切换键按下DelayUs(100OO);按键去抖if(KEY=O);pic+;if(pic3)pic=0;/*END*/DB40HOOH20HOOHDOH3FH4CH40H;DB43H44H44H48HC8H47HIOH40H;DB20H70HOOHOOHF8UOFHOOH40H;DBOOH80HFFH7FHOOHOOHOOHOoH;创,ODB0020H09H20HEBH2BHA5HAH;DBA5H6AHAlH3E
15、HBFH2HEOH2BH;DBA9H2AHBH3EH5H6AH5HH;DBElH2BUIFH20HOOH20HOOHOOH:翼,1创(O)翼(1)0x40,OxOO10x20,OxOO1OxDO,0x3F,0x4C,0x40,0x43,0x44,0x44,0x48,0xC8,0x47,0x10,0x40,0x20,0x70,0x00,OxOO10xF8,OxOF,0x00,0x40,0x00,0x80,OxFF,0x7F,0x00,0x00,0x00,0x00,/*创,O*/0x00,0x20,0x09,0x20,OxEB,0x2B,0xA5,OxAA),0xA5,0x6,0x1,0x3E,OxBE,0x2,OxEO10