【正文】
1 摘要 本設計主要是利用 AT89S52 單片機來對電子琴的主體部分進行設計,用以實現(xiàn)電子琴的基本功能。本設計主要運用了 AT89S52 單片機的定時、中斷功能,利用 定時器可發(fā)出不同頻率的脈沖,不同頻率的脈沖經(jīng)喇叭驅(qū)動電路放大后,就會發(fā)出不同音調(diào)。 定時器按設計的定時參數(shù)產(chǎn)生中斷,這一次中斷發(fā)出脈沖低電平,下一次取反發(fā)出脈沖高電平,由于定時參數(shù)不同,就發(fā)出不同頻率的脈沖。 本制作中巧妙地利用了單片機的定時器,讓定時器中斷一次就改變喇叭的狀態(tài)一次,即形成矩形方波 頻率信號 , 每個頻率信號對應不同的音 階 ,再分別由對應的按鍵控 制 ,當相應的按鍵按下后便可產(chǎn)生相應的音調(diào)。 關鍵詞 : AT89S52 單片機、按鍵、揚聲器、電子琴 2 Abstract This design was mainly used for electronic AT89S52 SCM design, the main part to the basic function of the an. This design is mainly used for the timing and AT89S52 SCM interrup t function, use a different frequency timer can pulse frequency, different pulse amplification filtering through speakers, after driving circuit will be issued a different tone. According to the design of the timer interruption, the timing parameters generated a low level, a pulse interruption take the next time a pulse timing parameters, due to the high level is different in different frequency, pulse. The ingenious use of singlechip timer, let the timer interrupt time to change the state of speakers, forming a rectangular pulse frequency signal, each frequency signal corresponding different syllable, then respectively by the corresponding key control, when the corresponding key press and can produce the corresponding tones. Keywords: AT89S52 SCM, buttons, speaker, keyboard 3 目 錄 前 言 ................................................................... 1 第一章 電子琴總體設計及原理 .......................................... 2 第一節(jié) 電子琴 總體結構設計 ................................................. 2 第 二 節(jié) 電子琴的基本原理 ................................................... 3 第二章 電子琴硬件設計 ................................................. 4 第一節(jié) AT89S52 單片機簡介 ................................................... 4 第二節(jié) 各 電路模塊設計 ..................................................... 5 第三章 電子琴軟件設計 ................................................... 8 第一節(jié) 電子琴主程序設計 ................................................... 8 第二節(jié) 電 子琴子程序設計 ................................................... 9 第四章 調(diào)試規(guī)程 ......................................................... 11 參考文獻 ................................................................. 12 致 謝 ................................................................... 13 附錄一 電子琴電路原理圖 .............................................. 14 附錄二 電子琴程序清單 ........................