單片機(jī)的流水燈設(shè)計(jì)_第1頁
單片機(jī)的流水燈設(shè)計(jì)_第2頁
單片機(jī)的流水燈設(shè)計(jì)_第3頁
單片機(jī)的流水燈設(shè)計(jì)_第4頁
單片機(jī)的流水燈設(shè)計(jì)_第5頁
已閱讀5頁,還剩5頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

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

文檔簡介

單片機(jī)的流水燈設(shè)計(jì)文章目錄一、前言花樣流水燈就是讓LED燈按照一定規(guī)律進(jìn)行各種變化,流水燈在生活中也隨處可見,例如在建筑物的棱角上裝上流水燈,可以起到變換閃爍達(dá)到美不勝收的效果。此設(shè)計(jì)使用16個(gè)LED燈,有四種花樣,循環(huán)往復(fù)顯示,每隔15S左右的時(shí)間進(jìn)行一次花樣變換。也可手動(dòng)切換花樣。單片機(jī)系統(tǒng)裝有按鍵復(fù)位電路可直接復(fù)位電路。二、模塊介紹及原理說明單片機(jī)最小系統(tǒng):單片機(jī)最小系統(tǒng)完成系統(tǒng)運(yùn)行的最基本電路,單片機(jī)最小系統(tǒng)可配合其他模塊或自行搭建電路完成各種實(shí)驗(yàn)功能,單片機(jī)最小系統(tǒng)接口設(shè)計(jì)靈活,電路簡潔,可完成基本的驅(qū)動(dòng)任務(wù)。單片機(jī)最小系統(tǒng)包括晶振電路、復(fù)位電路。復(fù)位電路我使用按鍵復(fù)位,方便系統(tǒng)的重啟。三、硬件連接本設(shè)計(jì)使用P0、P2控制LED燈由于LED燈所需電量少,所以不需要加驅(qū)動(dòng)就可以完成顯示。P3^0為按鍵控制端口,用于控制花樣燈的切換。仿真連接實(shí)物連接四、程序說明主程序,用以調(diào)用不同的函數(shù)。main({Timer0Init(;//定時(shí)器0初始化P2=0x00;//端口初始化P0=0x00;while(1){key(;if(num==0){P2=0x00;P0=0x00;}elseif(num==1)num1(;//花樣一elseif(num==2)num2(;//花樣二elseif(num==3)num3(;elseif(num==4)num4(;}}。定時(shí)器函數(shù),用來控制不同花樣切換的時(shí)間,更加準(zhǔn)確,此設(shè)計(jì)控制每種花樣的顯示時(shí)間為15S,可根據(jù)喜好自己調(diào)節(jié)。voidTimer0(interrupt1{TH0=(65536-6000)/256;//給定時(shí)器賦初值,定時(shí)10msTL0=(65536-6000)%256;ssec++;if(ssec>=100)//毫秒時(shí)鐘{ssec=0;sec++;if(sec>=15)//秒{sec=0;num++;}if(num==5)num=1;}}?;颖砀窈瘮?shù),將各種花樣流水燈分開放入表格中,在主函數(shù)中進(jìn)行調(diào)用。通過查表的方式顯示各種花樣,實(shí)用性更強(qiáng),在花樣較多時(shí)也方便進(jìn)行管理。花樣相對簡單,可自己進(jìn)行編寫。unsignedcharcodeseg1[]={0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe,0xff,0xff,0x00,0x00,0x55,0x55,0xaa,0xaa};//第一種unsignedcharcodeseg2[]={0x01,0x03,0x07,0x0f,0x1f,0x3f,0x7f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff};unsignedcharcodeseg3[]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xc0,0xe0,0xf0,0xf8,0xfc,0xfe,0xff,};//第二種unsignedcharcodeseg4[]={0x01,0x03,0x07,0x0f,0x1f,0x3f,0x7f,0xff,0xff,0x7f,0x3f,0x1f,0x0f,0x07,0x03,0x01};unsignedcharcodeseg5[]={0x01,0x03,0x07,0x0f,0x1f,0x3f,0x7f,0xff,0xff,0x7f,0x3f,0x1f,0x0f,0x07,0x03,0x01};//第三種unsignedcharcodeseg6[]={0x00,0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80,0x00,0x00,0x00,0x00,0x00,0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80,0x00,0x00,0x00,0x00,0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80,0x00,0x00,0x00,0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80,0x00,0x00,0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80,0x00,0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80,0x81,0x82,0x84,0x88,0x90,0xa0,0xc0,0xc1,0xc2,0xc4,0xc8,0xd0,0xe0,0xe1,0xe2,0xe4,0xe8,0xf0,0xf1,0xf2,0xf4,0xf8,0xf9,0xfa,0xfc,0xfd,0xfe,0xff};unsignedcharcodeseg7[]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x81,0x41,0x21,0x11,0x09,0x05,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x83,0x43,0x23,0x13,0x0b,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x87,0x47,0x27,0x17,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x8f,0x4f,0x2f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x9f,0x5f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0xbf,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,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,};//第四種。按鍵函數(shù),可以通過按鍵進(jìn)行LED燈花樣的切換,按鍵函數(shù)中需要加入消抖函數(shù),以防止按鍵誤觸。voidkey({if(key1==0)//按鍵控制{delay(10);if(key1==0){num++;if(num==5)num=0;}while(!key1);//檢測按鍵是否松開}}。五、效果演示仿真演示

溫馨提示

  • 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)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論