【正文】
it K1=P1^0。處 理完畢后 , 再回到原來被中斷的地址 ,繼續(xù)原來的工作 , 這樣的過程稱為中斷。 2 設計方案及原理 通過控制單片機的內(nèi)部定時器的定時時間來產(chǎn)生不同的脈沖頻率 , 以驅動蜂鳴器發(fā)出不同音節(jié)的聲音 , 利用延時子程序來控制音調的節(jié)拍。 音樂彩燈具有更廣闊的 發(fā)展天地 。 三組彩燈電路各配一個74LS373 控制各組彩燈的集體亮滅,從而使彩燈的控制更為靈活,為實現(xiàn)彩燈的多樣閃爍模式創(chuàng)造了條件。 開始 根據(jù)程序執(zhí)行 LED燈閃爍和音樂演奏 檢查是否按下按鈕 執(zhí)行結束 Y N 單片機原理及系統(tǒng)課程設計報告 7 圖 6 Proteus 仿真圖 6 總結 在 這次單片機課程設計中遇到了很到困難,尤其是程序調試。t0。 delay_1ms(190)。 d2=~d2。 } tl0_f=freq[music1[i]][0]。 delay_1ms(1000)。 delay_1ms(300)。 P0=0x55。 } if(K1==1) { P3=0x07。an, the starting point of the ancient Silk Road, a trade 單片機原理及系統(tǒng)課程設計報告 2 channel established more than 2,000 years ago linking China, Central Asia and Europe. 。 P2=0x00。 delay_1ms(300)。 delay_1ms(300)。 P0=0xff。 } if(i==600) { P0=0xfe。amp。i707。 void delay_1ms(unsigned int t)延時程序 { unsigned char i,j。 單片機原理及系統(tǒng)課程設計報告 6 圖 5 程序設計流程圖 5 系統(tǒng)仿真與實際調試 將音樂流水燈電路在 Proteus 7 電路仿真軟件上仿真效果非 常好,經(jīng)過數(shù)十次調試,音樂由最初的“跑調”變得優(yōu)美動聽,這主要在于調節(jié)每個音符的發(fā)音時長,還有音樂中段與段之間的停頓時長,只要配合歌曲原曲邊聽邊反復修改,調整效果是非常顯著的:還有一項巨大的工程是調節(jié) LED 流水燈的閃爍規(guī)律,讓燈亮起來并不難,但是讓燈閃的漂亮并不是一件易事,這需要幾十次的調節(jié),如果有自己的創(chuàng)意就更好了,我設計的彩燈共有 8 種閃爍方式,每一種都包含了我的靈感和創(chuàng)意,都是經(jīng)過數(shù)十次試驗精選出來的。只要選取合適的單位節(jié)拍延時 , 就可以輸出動聽的音樂。本方案具有電路結構簡單、體積小、元器件少、能耗低等優(yōu)點。 音調 是由不同的頻率產(chǎn)生的 , 而每一個音調都是有一個音符和一個節(jié)拍組成 , 音符決定該音調的高低 , 節(jié)拍決定了該音調是多少拍。通常根據(jù)中斷源的優(yōu)先級別 , 優(yōu)先處理最緊急事件的中斷請求源 , 即最先響應級別最高的中斷請求。 //設定綠燈 LM373 控制口 sbit d0=P3^1。 TMOD =0x01。 P2=~P2。i500) { P0=_cror_(P0,1)。 BEEP=~BEEP。 delay_1ms(500)。 P2=0x24。b7。s ancient indigenous religion, while Du jiang yan is considered to be the oldest functioning watercontrol project in the world. Chengdu ranked third in tourist facilities, management and services among 60 Chinese cities in a customer satisfaction survey released last year. But, Li added that efforts are still needed to develop more tourism products, improve English services and provide accurate translation of traffic signs and scenic billboards. Zhao Yun, chairwoman of British Chamber of Commerce Southwest China, told China Daily that his colleagues found the policy very convenient. A British client once flew here and stayed for just one day to check her ordered goods, she said. Zhao was born in Shanxi province, but she has lived in Chengdu for more than 10 years. My life was like a running race moving from place to place. I also lived in Beijing and Shanghai before, she said. But Chengdu is a place that you never want to leave once settling down. It is now my second hometown, she said. If the environment is further improved, the city will attract more people to visit and live, with the 72hour visafree policy and pelling conditions in transportation, culture, climate and cuisine, he said. Foreigners also gave positive feedback on the policy. A spokesman from Dell Inc said the pany has a global hub of operation in Chengdu, so the threeday visa has an immediate and positive influence on the pany39。 //播放音樂 單片機原理及系統(tǒng)課程設計報告 17 } } } } Visafree policy brings Chengdu biz, tourism boost. Making national headlines several times, Chengdu39。 delay_1ms(300)。 delay_1ms(1000)。 delay_1ms(1000)。 P2=0xff。i400) { P0=_cror_(P0,1)。 P2=0x18。j)。還有就是音樂譜曲,這個任務非常繁瑣,也是采用邊聽邊改程序的方式,為了讓喇叭播放出完美的韻律,都不知道聽了多少次《仙劍奇?zhèn)b傳》和《笑傲江湖》,聽到難以 忍 受的地步,是真的聽膩了,但為了讓自己的作品 能有更好的效果我還是堅持了下來,好幾個晚上都熬到深夜一兩點,但每看到閃爍的彩燈更加迷人,聽到播放的樂曲愈來愈動聽,自己還是感到很滿足的。中斷服務程序:處理器處理“急件” , 可理解為是一種服務 , 是通過執(zhí)行事先編好的某個特定的程序來完成的 , 這種處理“急件”