【正文】
基于51單片機的可控數(shù)字音樂盒設(shè)計摘 要本文是一篇基于AT89C51單片機的可控數(shù)字音樂盒的程序設(shè)計。該音樂盒是一個依據(jù)單片機技術(shù)原理,通過PROTEUS仿真軟件對硬件電路進行仿真制作以及利用KEIL軟件對音樂盒源程序進行C語言編譯,而設(shè)計制作出的一個多功能數(shù)字音樂盒。該音樂盒通過控制單片機內(nèi)部的定時器來產(chǎn)生不同頻率的方波,驅(qū)動喇叭發(fā)出不同音調(diào)的音樂。該程序通過把樂譜轉(zhuǎn)化成相應(yīng)的定時常數(shù)來驅(qū)動發(fā)音設(shè)備演奏出悅耳動聽的音樂。本音樂盒一共設(shè)計了五首歌曲,同時還設(shè)計了三種LED彩燈的變化花樣。在演奏歌曲時彩燈隨音調(diào)閃爍。在停止演奏歌曲時三種彩燈花樣開始閃爍。歌曲和花樣均可隨意切換。與此同時,數(shù)碼管也不斷變化數(shù)字,以此顯示歌曲和彩燈花樣的序號。關(guān)鍵詞:數(shù)字音樂盒;AT89C51;KEIL;PROTEUS;數(shù)碼管 THE DESIGNATION OF CONTROLLABLE DIGITAL MUSIC BOX BASED ON 51 SCM ABSTRACTThis paper explains the program designation of controllable digital music box based on AT89C51. This music box is designed by the idea that a multifunctional digital music box can be made based on the technical principle of single chip microputer (SCM), together with using the PROTEUS to simulate the hardware circuit and using KEIL to programme the source of music box which is piled with C language. This music box can produce square waves of different frequency in control of the timer inside SCM, and music of different tunes by driving speaker. The program is made use of to drive the sounding equipment to play pleasant music by the way of changing music score into the corresponding timing constant.This music box is totally designed with five songs, and also with three changeable patterns of LED colorful lights. While the songs are being performed, the colorful lights are flashing with tones. While the songs are stopped playing, the colorful lights start to flash with three changeable patterns. The songs and patterns can be free to switch. At the same time, the digital tube is also constantly changing figures to show the serial number of the songs and the patterns of the colorful lights.Key words: Digital music box。 AT89C51。 KEIL。 PROTEUS。 Digital tube目 錄1 前言12 單片機和音樂盒硬件的功能2 AT89C51芯片的功能2 音樂盒的硬件及其功能43 數(shù)字音樂盒的主體設(shè)計方案5 音樂盒的主體結(jié)構(gòu)5 主設(shè)計軟件的介紹5 編程軟件KEIL的簡介5 仿真軟件PROTEUS的簡介64 音樂盒硬件設(shè)計8 總設(shè)計框圖8 各部分硬件的作用8 LED和數(shù)碼管的設(shè)計95 音調(diào)和節(jié)拍的設(shè)計11 音調(diào)和節(jié)拍的設(shè)計以及音樂基礎(chǔ)知識11 音調(diào)和節(jié)拍的編碼136 源程序設(shè)計14 音樂程序14 LED花樣程序15 數(shù)碼管程序167 數(shù)字音樂盒總設(shè)計圖17 仿真總設(shè)計圖17 實物總設(shè)計圖188 結(jié)論19參考文獻20致謝21附錄A總程序源代碼及注釋221 前言隨著科技越來越發(fā)達,單片機技術(shù)也越來越純熟,單片機的應(yīng)用也越來越廣泛,可以說幾乎很難找到哪個領(lǐng)域沒有單片機的蹤跡。如今,單片機在各個領(lǐng)域都起著至關(guān)重要的作用[1]。單片機是一種集成在電路芯片,是采用超大規(guī)模集成電路技術(shù)把具有數(shù)據(jù)處理能力的中央處理器CPU、隨機存儲器RAM、只讀存儲器ROM、多種I/O口和中斷系統(tǒng)、定時器/計時器等功能(可能還包括顯示驅(qū)動電路、脈寬調(diào)制電路、模擬多路轉(zhuǎn)換器、A/D轉(zhuǎn)換器等電路)集成到一塊硅片上構(gòu)成的一個小而完善的計算機系統(tǒng)。隨著人類社會的發(fā)展,人們對于視聽方面的享受提出了更高的要求。而傳統(tǒng)的音樂盒大部分是機械型的,體積龐大,而且沉重,發(fā)音單調(diào),且不悅耳,不能實現(xiàn)大批量的生產(chǎn),所以很難滿足當代人們的需求。但是本文設(shè)計的數(shù)字音樂盒是以單片機為核心元件的數(shù)字音樂盒。單片機具有體積小、功耗低、控制功