搖搖棒制作資料講解_圖文_第1頁
搖搖棒制作資料講解_圖文_第2頁
搖搖棒制作資料講解_圖文_第3頁
搖搖棒制作資料講解_圖文_第4頁
搖搖棒制作資料講解_圖文_第5頁
已閱讀5頁,還剩10頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認(rèn)領(lǐng)

文檔簡介

1、LED搖搖棒的詳細(xì)制作資料 LED搖搖棒很好地利用了人眼的視覺暫留特性。下圖是基于51單片機控制、16只高亮度LED發(fā)光二極管構(gòu)成的搖搖棒,配合手的左右搖晃就可呈現(xiàn)一幅完整的畫面,可以顯示字符、圖片等。演示效果見自制LED搖搖棒展示【圖】。    黑暗條件下拍攝的效果圖片:    實物外形圖:基本原理與硬件電路設(shè)計:        16只LED發(fā)光管作為畫面每一列的顯示,左右搖晃起到了掃描的作用,人眼的視覺暫留現(xiàn)象使得看到的是一幅完整的畫面。與LED點陣的

2、顯示有幾分相仿。        硬件電路如下圖(點擊可放大)。系統(tǒng)電源VCC為5V,下載程序和調(diào)試時一定要保證5V電壓,實際使用時用3節(jié)干電池串聯(lián)4.5V即可。AT89S52單片機作為控制器,在它的P0、P2口接有16只以共陽的方式連接的高亮度LED,由單片機輸出低電平點亮。P0口的上拉電阻RA1不能少。串在LED公共端的二極管D1會產(chǎn)生一定的壓降,用來保護LED,經(jīng)實測LED點亮?xí)r兩端電壓為3V左右,在LED的安全承受范圍內(nèi)。K1是畫面切換開關(guān),用于切換顯示不同內(nèi)容;S1為水銀開關(guān)。水銀開關(guān)的作用:棒在搖動時,只能在朝某一

3、方向搖動時顯示,否則會出現(xiàn)鏡像字或鏡像畫面,所以通過接一只水銀開關(guān)來控制,使搖搖棒從左向右搖動時將內(nèi)容顯示出來。硬件制作:使用的是直徑5mm的紅色高亮LED,感覺太大了些,遠(yuǎn)看效果很好但近看時字不夠連貫。建議使用直徑為3mm的高亮LED,顏色可根據(jù)個人喜好選擇。水銀開關(guān)里的水銀珠很活躍,導(dǎo)致在接通時容易產(chǎn)生抖動,所以將水銀開關(guān)斜向上放置(尖尖朝斜上方45°角),靠水銀珠自身重力的作用減少抖動:IC座里面隱藏元件,既美觀又能保護元件:軟件設(shè)計:/*程序名稱:LED搖搖棒顯示64*16像素簡要說明:外部中斷方式INT0顯示;取模方式:縱向取模、字節(jié)倒序編   

4、; 寫:JiangX.net最后更新:08/11/15晚*/#include #define uchar unsigned char#define uint unsigned int    /宏定義#define KEY P3_0      /定義畫面切換按鍵uchar KY;      /KY作用在后面說明     uchar disp;    

5、 /顯示漢字指針uchar pic=0,num=0;     /pic為按鍵次數(shù);num為中斷次數(shù)uchar code love = 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x3F,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x0

6、0,0x00,0x00,0x00,0x00,0x00,0xF8,0x0F,0x04,0x10,0x02,0x20,0x02,0x20,0x02,0x20,0x02,0x20,0x04,0x10,0xF8,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x07,0x00,0x08,0x00,0x10,0x00,0x20,0x00,0x20,0x00,0x10,0x00,0x08,0xFE,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x3F,0x82,0x20,0x82,0x20,0x82,0x20,0x82,0x20,0x8

7、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,/*LOVE*/;uchar code loveyou = 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,0x0

8、0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x78,0x00,0xFC,0x00,0xFE,0x01,0xFE,0x03,0xFE,0x07,0xFE,0x0F,0xFE,0x1F,0xFC,0x3F,0xF8,0x7F,0xFC,0x3F,0xFE,0x1F,0xFE,0x0F,0xFE,0x07,0xFE,0x03,0xFE,0x01,0xFC,0x00,0x78,0x00,0x00,0x00,0x00,0x00,0x0

9、0,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,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*心形圖案*/;uchar code hehe = 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0

10、x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x01,0x40,0x01,0xC0,0x01,0x00,0x00,0x00,0x00,0xF0,0x0F,0x08,0x10,0x04,0x20,0x00,0x00,0x00,0x00,0xF0,0x3F,0x08,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x08,0x00,0xF0,0x3F,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x00,0x00,0

11、x00,0xF0,0x3F,0x08,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x08,0x00,0xF0,0x3F,0x00,0x00,0x00,0x00,0x04,0x20,0x08,0x10,0xF0,0x0F,0x00,0x00,0x00,0x00,0xC0,0x01,0x40,0x01,0xC0,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*呵呵o(_o圖案*/;unsigned char

12、 code hanzi = /- 歡 -      0x04,0x10,0x34,0x08,0xC4,0x06,0x04,0x01,      0xC4,0x82,0x3C,0x8C,0x20,0x40,0x10,0x30,      0x0F,0x0C,0xE8,0x03,0x08,0x0C,0x08,0x10,      0x28,0x60,0x18,0xC0,0x00,0x40,0x00,0

13、x00,/- 迎 -      0x40,0x00,0x42,0x40,0x44,0x20,0xC8,0x1F,      0x00,0x20,0xFC,0x47,0x04,0x42,0x02,0x41,      0x82,0x40,0xFC,0x7F,0x04,0x40,0x04,0x42,      0x04,0x44,0xFE,0x63,0x04,0x20,0x00,0x00,/- 使 -

14、      0x40,0x00,0x20,0x00,0xF8,0xFF,0x07,0x00,      0x04,0x80,0xF4,0x43,0x14,0x45,0x14,0x29,      0x14,0x19,0xFF,0x17,0x14,0x21,0x14,0x21,      0x14,0x41,0xF6,0xC3,0x04,0x40,0x00,0x00,/- 用 - 

15、0;    0x00,0x80,0x00,0x60,0xFE,0x1F,0x22,0x02,      0x22,0x02,0x22,0x02,0x22,0x02,0xFE,0x7F,      0x22,0x02,0x22,0x02,0x22,0x42,0x22,0x82,      0xFF,0x7F,0x02,0x00,0x00,0x00,0x00,0x00,/- 神 -   &#

16、160;  0x08,0x01,0x88,0x00,0x49,0x00,0xEE,0xFF,      0x58,0x00,0x88,0x00,0x00,0x00,0xF8,0x1F,      0x88,0x08,0x88,0x08,0xFF,0xFF,0x88,0x08,      0x88,0x08,0xFC,0x1F,0x08,0x00,0x00,0x00,/- 奇 -     

17、 0x40,0x00,0x40,0x00,0x44,0x00,0x44,0x3E,      0x64,0x12,0x54,0x12,0x4C,0x12,0x47,0x12,      0x4C,0x3F,0x54,0x42,0x74,0x80,0xC6,0x7F,      0x44,0x00,0x60,0x00,0x40,0x00,0x00,0x00,/- 魔 -      0x00,0x40

18、,0x00,0x30,0xFE,0x8F,0x4A,0x80,      0xAA,0x5F,0x9A,0x4A,0xFE,0x2A,0xAA,0x1A,      0xCB,0x0F,0xAA,0x7A,0xFE,0x8A,0x9A,0xAA,      0xAA,0x8F,0x6B,0x80,0x22,0xE0,0x00,0x00,/- 幻 -      0x80,0x20,0xC0,0x30

19、,0xA0,0x28,0x98,0x24,      0x87,0x22,0x80,0x21,0xC4,0x30,0x04,0x60,      0x04,0x00,0x04,0x20,0x04,0x40,0x04,0x80,      0x04,0x40,0xFE,0x3F,0x04,0x00,0x00,0x00,/- 搖 -      0x10,0x02,0x10,0x42,0x10,0x81

20、,0xFF,0x7F,      0x90,0x04,0x54,0x05,0xCC,0xF4,0xB4,0x44,      0x84,0x44,0xBC,0x7F,0x82,0x44,0xA2,0x44,      0x9B,0xF4,0x82,0x06,0x00,0x04,0x00,0x00,/- 搖 -      0x10,0x02,0x10,0x42,0x10,0x81,0xFF,0x7F

21、,      0x90,0x04,0x54,0x05,0xCC,0xF4,0xB4,0x44,      0x84,0x44,0xBC,0x7F,0x82,0x44,0xA2,0x44,      0x9B,0xF4,0x82,0x06,0x00,0x04,0x00,0x00,/- 棒 -      0x10,0x04,0x10,0x03,0xD0,0x00,0xFF,0xFF, 

22、60;    0x90,0x00,0x54,0x05,0x44,0x12,0xD4,0x15,      0x74,0x14,0x5F,0xFF,0xD4,0x14,0x54,0x15,      0x56,0x12,0x44,0x06,0x40,0x02,0x00,0x00,/- ! -      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,   &

23、#160;  0x00,0x00,0x00,0x00,0x7C,0x10,0xFE,0x3B,      0xFE,0x3B,0x7C,0x10,0x00,0x00,0x00,0x00,      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00;/*函數(shù)聲明*/void display1(void;void display2(void;void display3(void;void display4(void;/*n(us)延時子程序*/void Del

24、ayUs(uint N uint x; for(x=0; x<=N;x+;/*中斷服務(wù)程序*/void intersvr0(void interrupt 0 using 1 KY=KY;      /每個搖動來回水銀開關(guān)會在擺幅兩端分別產(chǎn)生下降沿中斷,只提取其中一次(從左向右搖才顯示) if(KY=0   num+;     /計算中斷次數(shù)  switch(pic  &#

25、160;   /選擇畫面     case 0:display1(;break;   case 1:display2(;break;   case 2:display3(;break;   case 3:display4(;break;   default:display1(;        /*顯示子程序1(漢字)*/void

26、 display1(void uchar i; if(num>10disp+;num=0;     /12個漢字分為3次顯示完(每次顯示4個),每中斷10次切換 if(disp>2disp=0;  DelayUs(5200;     /此處延時時間依各硬件差別而各不相同,試著調(diào)整使得顯示內(nèi)容居中即可 for(i=0;i<64;i+      P0=hanzidisp*128+i*2;     P2=hanzidisp*128+i*2+1;     DelayUs(100; /*顯示子程序2(LOVE)*/void display2(void uchar i; DelayUs(4000; for(i=0;i<64;i+      P0=lovei*2;   &#

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論