《LED摇摇棒的详细制作资料_0.docx》由会员分享,可在线阅读,更多相关《LED摇摇棒的详细制作资料_0.docx(12页珍藏版)》请在三一办公上搜索。
1、1.ED摇摇棒的具体制作资料1.ED摇摇棒的具体制作资料1.ED摇摇棒的具体制作资料【图】大家知道,人的眼睛存在视觉暂留现象,正因为眼睛的反应迟钝,才丰富了人的视觉感受。1.ED摇摇棒很好地利用/人眼的视觉衡留特性。下图是基于51单片机限制、16只高亮度1.ED发光二极管构成的摇摇棒,协作手的左右摇摆就可呈现一幅完整的画面,可以显示字符、图片等。演示效果见自制1.ED摇摇棒展示【图】0实物外形图(点击可放大):基本原理与硬件电路设计:16只1.ED发光管作为画面每一列的显示,左右摇摆起到了扫描的作用,人眼的视觉暂留现象使得看到的是一幅完整的画面。与1.ED点阵的显示有几分相仿。硬件电路如下图(
2、点击可放大)。系统电源VCC为5V,下载程序和调试时肯定要保证5V电压,实际运用时用3节干电池串联4.5V即可。AT89S52单片机作为限制器,在它的PO、P2口接有16只以共阳的方式连接的高亮度1.ED,由单片机输出低电平点亮。PO口的上拉电阻RAl不能少。串在1.ED公共端的二极管Dl会产生肯定的压降,用来爱护1.ED,经实测1.ED点亮时两端电压为3V左右,在1.ED的平安承受范围内。Kl是画面切换开关,用于切换显示不同内容:Sl为水银开关。水银开关的作用:棒在摇动时,只能在朝某一方向摇动时显示,否则会出现镜像字或镜像画面,所以通过接一只水银开关来限制,使摇摇棒从左向右摇动时将内容显示出
3、来。硬件制作:运用的是宜径5mm的红色高亮1.ED,感觉太大了些,远看效果很好但近看时字不够连贯。建议运用宜径为3mm的高亮1.ED,颜色可依据个人喜好选择。水银开关里的水银珠很活跃,导致在接通时简单产生抖动,所以将水银开关斜向上放置(尖尖朝斜上方45角),靠水银珠自身重力的作用削减抖动:IC座里面隐藏元件,既美观又能爱护元件:软件设计:/*程序名称:1.ED摇摇棒显示64*16像素简要说明:外部中断方式INTO显示:取模方式:纵向取模、字节倒序编写:JiangX最终更新:08/11/15晚*/#includeT89X52.h#defineucharunsignedchar#defineuin
4、tunsignedint/宏定义#defineKEYP3_0定义画面切换按键ucharKY:KY作用在后面说明uchardisp;显示汉字指针ucharpic=0,num=0;/pic为按键次数;num为中断次数ucharcodelove=0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,OxFE10x3F,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,
5、0x00,0x20,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0xF8,OxOF,0x04,0x10,0x02,0x20,0x02,0x20,0x02,0x20,0x02,0x20,0x04,0x10,0xF8,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,
6、0x82,0x20,0x82,0x20,0x82,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*/;ucharcodeloveyou0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
7、,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,OxOO10x00,0x00,0x78,0x00,OxFC,0x00,OxFE,0x01,OxFE,0x03,OxFE,0x07,OxFE,OxOF,OxFE,OxlF,OxFC,0x3F,0xF8,0x7F,OxFC,0x3F,OxFE,OxlF,OxFE,OxOF,OxFE,0x07,OxFE,0x03,OxFE,0x01,OxFC,0x00,0x78,0x00,0x00
8、,0x00,0x00,0x00,0x00,0x00,0x00,OxOO10x00,OxOO10x00,0x00,0x00,0x00,OxOO10x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*心形图案*/;ucharcodehehe=0x00,0x00,0x00,0x00,0x00,OxOO10x00,0x00,0x00,0x00,0
9、x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,OxCO,0x01,0x40,0x01,OxCO10x01,0x00,0x00,0x00,0x00,OxFO,OxOF,0x08,0x10,0x04,0x20,0x00,0x00,0x00,0x00,OxFO,0x3F,0x08,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x08,OxOO,OxFO10x3F,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0
10、x00,0x00,0x00,0x00,OxFO,0x3F,0x08,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x08,0x00,OxFO,0x3F,0x00,0x00,0x00,0x00,0x04,0x20,0x08,0x10,OxFO1OxOF,0x00,0x00,0x00,0x00,OxCO,0x01,0x40,0x01,OxCO10x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*呵呵o(_)o图案
11、*/;unsignedcharcodehanzi=/一欢一0x04,0x10,0x34,0x08,0xC4,0x06,0x04,0x01,0xC4,0x82,0x3C,0x8C,0x20,0x40,0x10,0x30,OxOF,OxOC,0xE8,0x03,0x081OxOC,0x08,0x10,0x28,0x60,0x18,OxCO,0x00,0x40,0x00,0x00,/迎0x40,0x00,0x42,0x40,0x44,0x20,0xC8,OxlF,0x00,0x20,OxFC,0x47,0x04,0x42,0x02,0x41,0x82,0x40,OxFC,0x7F,0x04,0x40
12、,0x04,0x42,0x04,0x44,OxFE,0x63,0x04,0x20,0x00,0x00,/-使0x40,0x00,0x20,0x00,0xF8,OxFF,0x07,0x00,0x04,0x80,0xF4,0x43,0x14,0x45,0x14,0x29,0x14,0x19,OxFF10x17,0x14,0x21,0x14,0x21,0x14,0x41,0xF6,0xC3,0x04,0x40,0x00,0x00,/用一0x00,0x80,0x00,0x60,OxFE,OxlF10x22,0x02,0x22,0x02,0x22,0x02,0x22,0x02,OxFE,0x7F,0x2
13、2,0x02,0x22,0x02,0x22,0x42,0x22,0x82,OxFF,0x7F,0x02,0x00,0x00,0x00,0x00,0x00,/一神一0x08,0x01,0x88,0x00,0x49,0x00,OxEE,OxFF,0x58,0x00,0x88,0x00,0x00,0x00,0xF8,OxlF,0x88,0x08,0x88,0x08,OxFF,OxFF10x88,0x08,0x88,0x08,OxFC,OxlF10x08,0x00,0x00,0x00,/一奇一0x40,0x00,0x40,0x00,0x44,0x00,0x44,0x3E,0x64,0x12,0x54,
14、0x12,0xC6,0x7F,0x44,OxOO10x60,OxOO10x40,0x00,0x00,0x00,一魔-0x00,0x40,0x00,0x30,OxFE,0x8F,0x4A,0x80,Ox,0x5F,0x9,0x4,OxFE,0x2A,OxA,Oxl,OxCB,OxOF,OxAA,0x7A,OxFE,0x8A,0x9A,OxAA,OxAA10x8F,0x6B,0x80,0x22,OxEO10x00,0x00,/幻0x80,0x20,OxCO,0x30,OxAO,0x28,0x98,0x24,0x87,0x22,0x80,0x21,0xC4,0x30,0x04,0x60,0x04,0
15、x00,0x04,0x20,0x04,0x40,0x04,0x80,0x04,0x40,OxFE,0x3F,0x04,OxOO10x00,0x00,/-摇一0x10,0x02,0x10,0x42,0x10,0x81,OxFF.0x7F,0x90,0x04,0x54,0x05,OxCC,0xF4,OXB4,0x44,0x84,0x44,OxBC,0x7F,0x82,0x44,0xA2,0x44,0x9B,0xF4,0x82,0x06,0x00,0x04,0x00,0x00,一摇一OxlO10x02,0x10,0x42,0x10,0x81,OxFF,0x7F,0x90,0x04,0x54,0x05
16、,OxCC,0xF4,0xB4,0x44,0x84,0x44,OxBC,0x7F,0x82,0x44,0xA2,0x44,0x9B,0xF4,0x82,0x06,0x00,0x04,0x00,0x00,/棒0x10,0x04,0x10,0x03,OxDO,0x00,OxFF,OxFF10x90,0x00,0x54,0x05,0x44,0x12,0xD4,0x15,0x74,0x14,0x5F.OxFF,0xD4,0x14,0x54,0x15,0x56,0x12,0x44,0x06,0x40,0x02,0x00,0x00,/!0x00,0x00,0x00,0x00,0x00,0x00,0x00,
17、0x00,0x00,0x00,0x00,0x00,0x7C,0x10,OxFE,0x3B,OxFE,0x3B,0x7C,0x10,0x00,0x00,OxOOlOxOO10x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00;/*函数声明*/voidClisplayl(void):voiddisplay2(void):voiddisplay3(void):voiddisplay4(void);*n(us)延时子程序*/voidDelayUs(uintN)uintx;for(x=0;x=N:x+);*t断服务程序*/voidintersvrO(void)interrupt
18、0using1KY=;每个摇动来回水银开关会在摆幅两端分别产生下降沿中断,只提取其中一次(从左向右摇才显示)if(KY=O)num+;计算中断次数switch(pic)选择画面case0:displayl();break;case1:(display2();break;case2:display3();break;CaSe3:display4();break;default:displayl();)/*显示子程序1(汉字)*/voiddisplayl(void)uchari;if(numl)disp+;num=0:/12个汉字分为3次显示完(每次显示4个),每中断10次切换if(disp2)d
19、isp=0;DelayUs(5200);此处延时时间依各硬件差别而各不相同,试着调整使得显示内容居中即可for(i=0:i64;i+)P0=hanzidisp*128+i*2:P2=hanzidisp*128+i*2+l;DelayUs(100);/*显示子程序2(1.OVE)*/voiddisplay2(void)uchari;DeIayUs(4000);for(i=0;i64;i+)(Po=lovei*2;P2=lovei*2+1;DelayUs(120):/*显示子程序3(心形图案)*/voiddisplay3(void)uchari;DelayUs(4000);for(i=0;i64;
20、i+)P0=IoveyouEi*2:P2=xIoveyoui*2+1;DeIayUs(120);/*显示子程序4(呵呵o(_)O图案)*/voiddisplay4(void)uchari;DelayUs(4000);for(i=0;i64;i+)P0=hehei*2;P2=hehei*2+1:DclayUs(120);/*主函数*/voidmain(void)ITO=I;EXO=I;EA=I;开中断,下降沿中断KY=O;WhiIe主程序中只检测按键If(KEY=O)画面切换键按下DelayUs(100OO);按键去抖if(KEY=O);pic+;if(pic3)PiC=0;*END*/*7it
21、FQ!2epMX-alwIT5hsDPttld5gsD0SIcozKV)8jvGR%4frCNYObmyJU(7iFQ3epBMX+a1wlT6hsE0bnyJU(7iuFQS3eqBMX+a1xIT*6hsEP#2do1.W-9kvHS%5grD0Z1cnyEth6*UIxma+YMBqe3$RFUj7(VJynb0Z0Crg4%SGvk9)W1.zodl#PDSh6d2#PEth6*TIx1a+XMBqe3SQFui7(UJynhOZNCrf4%SGvk8)WKzoclUPi7(UJymbOYNCrf4%RGvj8)VKzocl0Dsg5THwl9-X1.pd2!QEti6e3!QFti7
22、*UJxmbOYNCqf4SRGvj8)VKznc1ZoDSg5SHwk9-W1.pd2!uj8(VKync1ZODrg5%SHvk9-W1.Aod2#PEth6*TIx1a+XMBqC3$QFUiqf3$RFuj7(VKync0Z0Crg5%SHvk9)W1.ZOd2#PESh6TIwla+XMBpeSGvk8)W1.zodl#PDsh5TIwla-XMApe3!QFti7*UJxmbOYNCqf4$RGv-XMAPe2!QEti6*UJxmb+YNBqf4$RGuj8(VKynclZODrg5%SHwk9-WSHwl9-X1.Apd2!QEti6*UIxma+YNBqf3SRFuj7(VK
23、yncOZOCrg5%xma+YMBqe3$QFuj7(VJynbOZOCrg4%SGvk8)W1.zodlttPDsh6TIwEsh6*TIxla+XMBqe3$QFUi7(UJynbOZNCrf4%RGvk8)WKzoclitPD7(UJymbOYNCqf4%RGvj8)VKzoclS0Dsg5SHwl9-X1.pd2!QEti6*UIxma+YNBqf3$RFuj7(VKyncOZOCrgS%SHvk9)W1.zod2ttI1Esh6TIx1a+XBMX+alxIT*6hsEP2do1.W-9kvHS%5grDOZOcnyKV(8juGR$3fqBNY+bmxJl6itEQ!2cp1.X
24、-91wHT5hsDO#lcozKW)8jvGR%4fr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