⑴ 單片機音樂盒自己放歌
可以。單片機音樂盒依據單片機技術原理,通過硬體電路製作以及軟體編譯,設計製作出一個多功能多功能音樂盒,按照生產設定,可以進行自動放歌。單片機又稱微控制器,是一種面向控制領域嵌入式應用的集成化計算機晶元,主要用於工業控制、數據處理、信號處理、智能儀器、通信產品及民用消費產品等自動控制產品。
⑵ 急急急!!! 求AT89C51單片機實訓製作音樂盒程序編寫!以下為電路原理圖。謝謝...晶振是12M
OUT BIT P2.3 ;定義音頻輸出埠,p2.3
N EQU 9 ;歌曲總數
OUT_NUM EQU P0 ;數碼管顯視當前所放歌曲曲數
ORG 0000H
AJMP MAIN
ORG 0003H
AJMP LAST_SONG ;外部中斷0用於接上一曲歌按鍵
ORG 000BH
AJMP F_T0 ;定時器0用於定時,作音符發生器用
ORG 0013H
q4: AJMP NEXT_SONG ;外部中斷1接下一曲歌按鍵
ORG 001BH
AJMP START_PAUSE ;定時器1用計數,這里用作中斷,接開始/暫停鍵,初值為0ffH,方式2
ORG 0030H
MAIN: MOV SP,#60H
MOV DPTR,#TABLE ;DPRT指向每首歌曲的入口地址的地址。
MOV R0,#30H ;R0中存入數據30H,這里在以30H開始的單元存放每首歌曲的入口地址,其中30H,31H存放
;歌曲的節拍入口地址,32H,33H存放歌曲音符入口地址,每首歌佔用四個存儲存單元。
MOV R5,#00H ;R5中存放表TABLE中正在執行操作的序號
MOV R6,#1 ;R6存放正在設置入口信息的歌曲數
SET_TAB: MOV A,R5 ;設置每首歌曲的入口信息,存放在以30H開始的存儲單元中。
MOVC A,@A+DPTR
MOV @R0,A
INC R5
INC R0
MOV A,R5
MOVC A,@A+DPTR
MOV @R0,A
INC R5
INC R0
MOV A,R5
MOVC A,@A+DPTR
MOV @R0,A
INC R0
INC R5
MOV A,R5
MOVC A,@A+DPTR
MOV @R0,A
INC R0
INC R5
INC R6 ;設置完一首歌曲後,歌曲數加一
CJNE R6,#N+1,SET_TAB ;是否設置完,沒有便繼續,否則進行下面的操作
;*********************************** 對中斷,計數器的相關參數進行設置
MOV TMOD, #61H ;計數器0工作方式1,計數器1工作方式2
MOV TH1,#0FFH ;給計數器1置初值0FFH,又由於是工作方式2,所以
MOV TL1,#0FFH ;計數器計數為1,相當於一外部中斷。
SETB ET1 ;允許計數器1中斷
SETB ET0 ;允許計數器具0中斷
CLR PT0 ;計數器0為低優先順序
SETB PT1 ;計數器1為高優先順序
SETB IT0 ;外部中斷0為跳沿觸發
SETB PX0 ;高優先順序
SETB IT1 ;外部中斷1為跳沿觸發
SETB PX1 ;高優先順序
SETB EX1 ;允許外部中斷1中斷
SETB EX0 ;允許外部中斷定0中斷
SETB EA ;開中斷總開關
SETB TR1 ;定時器1開始工作,作中斷用
SETB OUT ;音頻輸出埠初始化
;*********************************** ;設置結束
CLR F0 ;設置F0=0,用來作暫停/播放的標置位用
MOV 22H,#01H ;22H單元中存放正在播放的歌曲編號
MOV DPTR,#OUT_TAB ;將正在播放的歌曲編號送數碼管顯視
MOV A,22H
MOVC A,@A+DPTR
MOV OUT_NUM,A
MOV R7,#00H ;R7中存放歌曲總信息的入口地址
START0:MOV R4,#00H ;R4存放當前正在播放歌曲的第幾個節拍數
MOV R0,#30H ;30H開始的單元中存放歌曲的入口信息
MOV A,R7 ;將歌曲的節拍表的入口地址送到DPTR
ADD A,R0
MOV R0,A
MOV DPH,@R0
INC R0
MOV DPL,@R0
INC R0
MOV A,R4
INC R4
MOVC A,@A+DPTR ;取出第一節拍數,其實第一個節拍不是歌曲的第一個節拍,而是表示幾分音符
;****************************************************
MOV 26H,A ;將取出的音符數+節拍數保存在職26H單元中
NEXT: MOV R0,#30H ;開始取出歌曲的第一個數據
MOV A,R7
ADD A,R0
MOV R0,A
MOV DPH,@R0
INC R0
MOV DPL,@R0
INC R0
MOV A,R4
INC R4
MOVC A,@A+DPTR ;放在A中
;****************************
JZ END0 ;若為0,則表示為休止符,不唱,本次音符不唱,
MOV R1,A ;不為0,取出節拍數
ANL A,#0FH
MOV R2,A
MOV A,R1
SWAP A
ANL A,#0FH
JNZ SING ;音符不為0,唱
CLR TR0 ;為0,不唱,關頻率發生器
SJMP SING1
SING: DEC A ;開始唱,進行相應的數據處理
MOV R3,A
RL A
MOV DPH,@R0
INC R0
MOV DPL,@R0
INC R0
MOVC A,@A+DPTR
MOV 21H,A
MOV TH0,A
MOV A,R3
RL A
INC A
MOVC A,@A+DPTR
MOV 20H,A
MOV TL0,A
SETB TR0 ;開唱
SING1:LCALL DELAY ;每個音符唱多久
JB F0,FOR ;是否暫停,
AJMP NEXT ;沒有暫停,繼續
FOR: CLR TR0 ;暫停,不唱
JB F0,$ ;等待播放
AJMP NEXT ;開始播放
END0: CLR TR0 ;不唱
MOV A,22H ;唱完處理
CJNE A,#N,WW ;是不是全部歌曲都唱完
MOV 22H,#01H ;全部唱完,則從第一首開始再唱
MOV R7,#00H
MOV OUT_NUM,#11111001B;數碼管顯視第一首歌曲編號
AJMP WWW
WW: MOV A,R7 ;沒有全部唱完,唱下一首,歌曲的入口信息調整
ADD A,#4
MOV R7,A
INC 22H
CLR EA
PUSH DPH
PUSH DPL
MOV A,22H
MOV DPTR,#OUT_TAB
MOVC A,@A+DPTR
MOV OUT_NUM,A ;數碼管顯視相應的歌曲編號
POP DPL
POP DPH
WWW: SETB EA
AJMP START0 ;開始下一首的演唱
F_T0: MOV TH0,21H ;定時器0置初值
MOV TL0,20H
CPL OUT ;頻率產生
RETI
NEXT_SONG: PUSH ACC ;下一曲中斷程序處理,保護現場
PUSH DPH
PUSH DPL
CLR EA ;關中斷
MOV A,22H
CJNE A,#N,Q ;是最後一首嗎?
MOV R7,#00H ;是最後一首,則R7指向第一首,演唱第一首
MOV 22H,#01H
AJMP BACK
Q: INC 22H ;不是最後一首,唱下一首,R7內容加4,歌曲數加1
MOV A,R7
ADD A,#4
MOV R7,A
BACK: MOV R4,#00H ;數碼管顯視相應的歌曲編號
MOV A,22H
MOV DPTR,#OUT_TAB
MOVC A,@A+DPTR
MOV OUT_NUM,A
;********************************************
MOV B,R0 ;對下首要演唱的歌曲的幾分拍進行調整,同時對R0中的內容進行保護
MOV R4,#00H
MOV R0,#30H
MOV A,R7
ADD A,R0
MOV R0,A
MOV DPH,@R0
INC R0
MOV DPL,@R0
INC R0
MOV A,R4
INC R4
MOVC A,@A+DPTR
MOV 26H,A ;結果存入26H單元中
DEC R4
MOV R0,B ;恢復R0中的內容
;********************************************
POP DPL ;恢復現場
POP DPH
POP ACC
SETB EA
RETI ;中斷返回
LAST_SONG: PUSH ACC ;上一曲中斷程序處理開始,保護現場
PUSH DPH
PUSH DPL
CLR EA ;關中斷
MOV A,22H ;曲目數送A
CJNE A,#1,QQ ;是否是第一首
MOV 22H,#N ;是第一首歌曲
MOV B,#4 ;將R7指向最後一首歌曲
MOV A,#N-1
MUL AB
MOV R7,A
AJMP BACK2 ;處理結束
QQ: DEC 22H
MOV A,R7 ;R7減4
SUBB A,#4
MOV R7,A
BACK2: MOV R4,#00H
MOV A,22H
MOV DPTR,#OUT_TAB
MOVC A,@A+DPTR
MOV OUT_NUM,A ;數碼管顯視相應歌曲的編號
;********************************************
MOV B,R0 ;對下首要演唱的歌曲的幾分拍進行調整,同時對R0中的內容進行保護
MOV R4,#00H
MOV R0,#30H
MOV A,R7
ADD A,R0
MOV R0,A
MOV DPH,@R0
INC R0
MOV DPL,@R0
INC R0
MOV A,R4
INC R4
MOVC A,@A+DPTR
MOV 26H,A ;結果存入26H單元中
DEC R4
MOV R0,B ;R0中的內容恢復
;********************************************
POP DPL ;恢復現場
POP DPH
POP ACC
SETB EA
RETI ;中斷返回
START_PAUSE:CPL F0 ;開始/暫停中斷處理程序,將標置位取反
JB F0,RETURN ;為1返回
SETB TR0 ;為0則播放
RETURN: RETI ;中斷返回
DELAY: MOV 27H,26H ;音符演奏時間控制
D2: MOV 28H,#125
D3: MOV 29H,#248
DJNZ 29H,$
DJNZ 28H,D3
DJNZ 27H,D2
DJNZ R2,DELAY
RET
;OUT_TAB: DB 3FH,06H,5BH,4FH,66H,6DH,7DH,07H,7FH,6FH,77H,7CH,39H,5EH,79H,71H,73H
;共陰數碼管顯視用
OUT_TAB: DB 0C0H,0F9H,0A4H,0B0H,99H,92H,82H,0F8H,80H,90H,88H,83H,0C6H,0A1H,86H,8EH,0FFH
;共陽
TABLE:
DW SONG1,TABLE1,SONG2,TABLE2,SONG3,TABLE3,SONG4,TABLE4 ,SONG5,TABLE5,SONG6,TABLE6,SONG7,TABLE7,SONG8,TABLE8
TABLE1:DW 64580,64684,64777,64820
DW 64898,64968,65030,64260
DW 64400,64524,65058,63835,64021
SONG1: ;精忠報國
DB 66H,52H,36H,22H,12H,12H,22H,32H,98H,84H,82H,92H,14H,12H,22H
DB 32H,52H,22H,42H,38H,66H,52H,36H,22H,12H,22H,22H,32H,98H
DB 24H,22H,32H,54H,52H,32H,92H,12H,92H,82H,98H,66H,52H,36H,22H
DB 12H,12H,22H,32H,98H,84H,82H,92H,14H,12H,22H,32H,52H,22H,42H,38H
DB 66H,52H,36H,22H,12H,22H,22H,32H,98H,24H,22H,32H,54H,52H,32H
DB 22H,12H,92H,82H,98H,14H,24H,34H,44H,64H,0B4H,64H,32H,52H
DB 62H,0B2H,62H,52H,38H,24H,22H,32H,54H,52H,62H,52H,32H,32H,22H,38H
DB 64H,0B4H,64H,32H,52H,62H,0B2H,62H,52H,38H,22H,22H,22H,32H,52H,52H
DB 52H,62H,7FH,74H,04H,58H,6FH
DB 00
TABLE2:DW 64580,64684,64777,64820
DW 64898,64968,65030,64260
DW 64400,64524,65058,63835,64021
SONG2: DB 02H,82H ;月亮代表我的心
DB 16H,32H,54H,02H,52H
DB 0A6H,32H,54H,02H,52H
DB 64H,74H,0B6H,64H
DB 52H,5CH,32H,22H
DB 16H,12H,14H,32H,22H
DB 16H,12H,14H,22H,32H
DB 26H,12H,94H,22H,32H
DB 2CH
DB 32H,52H
DB 36H,22H,14H,54H
DB 0ACH,92H,0A2H
DB 96H,0A2H,96H,82H
DB 3CH,54H
DB 36H,22H,14H,54H
DB 0ACH,92H,0A2H
DB 16H,12H,14H,22H,32H
DB 2CH,02H,82H
DB 16H,32H,56H,12H
DB 0A6H,32H,56H,52H
DB 66H,72H,0B6H,62H
DB 62H,52H,58H,32H,22H
DB 16H,12H,14H,32H,22H
DB 16H,12H,14H,22H,32H
DB 26H,92H,0A4H,12H,22H
DB 1CH
DB 00
TABLE3: DW 64580,64684,64777,64820
DW 64898,64968,65030,64260
DW 64400,64524,65058,63835,64021
SONG3: DB 0d4H,84H,94H,82H,92H ;看我七十二變
DB 12H,22H,82H,92H,02H,92H,82H,0d2H
DB 82H,92H,14H,84H,02H,0d1H,0d1H
DB 0c2H,0d2H,84H,0d2H,0d2H,82H,82H
DB 84H,82H,82H,94H,82H,0d2H
DB 82H,82H,82H,92H,02H,82H,82H,0d2H
DB 0c4H,84H,0d4H,92H,0d2H
DB 82H,0d2H,82H,92H,98H
DB 04H,94H,88H
DB 04H,94H,88H
DB 04H,94H,88H
DB 04H,94H,88H,04H
DB 32H,32H,22H,12H,02H,92H,12H,92H
DB 32H,32H,22H,12H,02H,92H,12H,92H
DB 32H,32H,22H,12H,02H,92H,12H,22H
DB 54H,44H,34H,12H,22H
DB 34H,22H,12H,02H,92H,12H,92H
DB 32H,32H,22H,12H,02H,92H,12H,92H
DB 32H,32H,22H,12H,02H,92H,12H,22H
DB 54H,44H,32H,22H,12H,92H
DB 00
TABLE4:DW 64580,64684,64777,64820
DW 64898,64968,65030,64260
DW 64400,64524,65058,63835,64021
SONG4:DB 82H,92H,12H,14H,12H,14H,92H,82H,12H,14H,22H,14H,92H,12H,22H,24H ;大海
DB 22H,24H,12H,92H,22H,24H,32H,24H,32H,52H,62H,54H,52H,64H,52H,32H
DB 22H,32H,22H,12H,94H,82H,92H,12H,14H,12H,14H,94H,1cH
DB 82H,92H,12H,14H,12H,14H,92H,82H,12H,14H,22H,14H,92H,12H,22H,24H
DB 22H,24H,12H,92H,22H,24H,32H,24H,32H,52H,62H,54H,52H,64H,52H,32H
DB 22H,32H,22H,12H,94H,82H,92H,12H,14H,12H,14H,22H,12H,1cH,32H,52H
DB 62H,64H,62H,64H,0b2H,62H,52H,54H,62H,54H,32H,22H
DB 12H,14H,12H,14H,24H,3cH,32H,22H,12H,14H,12H,14H,0b2H,62H,52H,54H,62H,54H,32H,52H
DB 66H,0b2H,0b4H,62H,52H,5cH,32H,52H,62H,64H,62H,64H,0b2H,62H,52H,54H
DB 62H,54H,32H,22H,12H,14H,12H,14H,54H,3cH,32H,22H,12H,14H,12H,14H,22H,32H
DB 52H,54H,32H,54H,32H,52H,6fH,04H,02H,92H,32H,24H,12H,1fH
DB 00
TABLE5:DW 64021,64103,64260,64400 ,64524,64580,64684,64777,64820,64898,64968,65030,64934
SONG5:DB 86H,92H,12H,22H,32H,52H,68H,63H,52H,34H,62H,0B2H,0B2H,62H,51H,61H,51H,31H,54H ;彩雲追月
DB 62H,0B2H,0B2H,62H,52H,32H,52H,52H,51H,61H,51H,31H,34H,52H,62H,74H,32H,52H,52H,32H,
DB 21H,31H,21H,11H,24H
DB 32H,52H,52H,32H,22H,12H,24H,32H,52H,52H,32H,62H,52H,61H,51H,
DB 31H,21H,21H,31H,21H,11H,1CH
DB 21H,31H,22H,23H,31H,21H,18H,02H,0B2H,0BCH,0B4H,72H,61H,51H,72H,61H,
DB 71H,61H,51H,61H,71H,61H,6FH
DB 86H,94H,12H,22H,32H,52H,64H,62H,51H,31H,52H,21H,31H,21H,33H,62H,0B2H,0B2H,62H,
DB 51H,61H,51H,31H,54H
DB 62H,0B2H,72H,61H,51H,51H,61H,51H,31H,54H,61H,0B2H,72H,61H,51H,51H,61H,51H,31H,32H,
DB 21H,11H,32H,51H,61H,54H
DB 02H,32H,24H,32H,52H,52H,32H,22H,31H,21H,11H,24H,32H,52H,62H,0B2H,72H,61H,51H,61H,
DB 51H,31H,32H,52H,52H,32H,62H
DB 51H,31H,31H,21H,11H,91H,23H,31H,21H,1CH,12H,24H,32H,62H,51H,31H,34H,0B4H,72H,
DB 61H,51H,63H,71H,64H
DB 0B2H,54H,72H,62H,71H,61H,54H,61H,51H,31H,21H,34H,73H,61H,54H,22H,32H,52H,22H,36H,
DB 52H,62H,61H,31H,32H,21H,11H,21H,11H,91H,81H
DB 94H,52H,62H,52H,42H,32H,22H,32H,52H,0B4H,74H,64H,52H,61H,51H,41H,5CH,02H,52H,0B4H,74H,
DB 63H,51H,61H,51H,31H,21H
DB 00
;*******************************************綠島小夜曲
TABLE6:DW 64021,6103,64260,64400,64524,64580,64624,64777,64820,64898,64958,65030,65058,65110,65157
SONG6: DB 06H
DB 0A2H,0B2H,0D2H,0B2H,0A4H,0B2H,0D2H
DB 0B2H,0A2H,82H,72H,88H
DB 72H,82H,0A2H,82H,72H,62H,42H,62H
DB 38H,38H
DB 0A4H,02H,0B2H,0A4H,84H
DB 72H,82H,72H,62H,72H,84H,72H
DB 64H,62H,12H,34H,02H,42H
DB 38H,38H
DB 44H,02H,32H,44H,64H
DB 72H,82H,72H,62H,72H,84H,0A2H
DB 72H,74H,82H,0A4H,02H,062H
DB 0A8H,0A8H
DB 0B2H,0B4H,0A2H,84H,82H,72H
DB 62H,72H,82H,0A2H,88H
DB 72H,74H,62H,42H,32H,32H,62H
DB 78H,78H
DB 82H,84H,72H,82H,0A2H,84H
DB 72H,82H,72H,62H,48H
DB 32H,0A2H,82H,0F2H,0A2H,0B2H,82H,72H
DB 68H,68H
DB 0B2H,0B2H,0B2H,0A2H,82H,84H,02H
DB 72H,74H,62H,42H,32H,42H,62H
DB 78H,78H
DB 0A2H,0B2H,0A2H,72H,82H,84H,82H
DB 72H,74H,62H,44H,64H
DB 0A8H,0A4H,02H,0A2H
DB 0A2H,0B1H,0A1H,82H,0A2H,0B4H,0B2H,0C2H
DB 0A2H,0B2H,0A2H,82H,78H
DB 84H,72H,62H,44H,02H,62H
DB 72H,81H,71H,62H,72H,84H,02H,0A2H
DB 0B4H,02H,82H,74H,82H,72H
DB 68H,68H
DB 00
TABLE7:
DW 64260,64400,64521,64580
DW 64684,64777,64820,64898
DW 64968,65030,65058,65110
DW 65157,65178,65217
SONG7: ;樂曲名稱《梁祝》
DB 02H,82H,62H,52H,48H,02H,52H,32H,22H,18H
DB 83H,91H,72H,62H,51H,61H,71H,61H,83H,61H
DB 81H,51H,61H,71H,61H,51H,46H,82H,32H,52H
DB 22H,42H,16H,21H,41H,18H,0E4H,13H,21H,43H
DB 51H,21H,41H,12H,83H,81H,61H,81H,58H,53H
DB 61H,31H,22H,13H,21H,42H,52H,0E2H,42H,21H
DB 11H,91H,41H,18H,63H,81H,32H,52H,21H,41H,
DB 16H,0E4H,11H,21H,31H,51H,26H,11H,21H,43H
DB 51H,82H,62H,52H,61H,51H,42H,21H,11H,0E4H
DB 44H,21H,41H,21H,11H,0E1H,11H,21H,41H,18H
DB 61H,81H,51H,61H,51H,41H,32H,21H,41H,18H
DB 08H,0H,04H ;曲子最後靜音5拍長的時間
DB 00H ;樂曲結束
TABLE8: ;決定音調的定時初值.
DW 64260,64400,64524,64580
DW 64684,64777,64820,64898
DW 64968,65030,65058,65110
DW 65157,65178,65217
SONG8: ;決定音調和節拍的表格,不同的歌曲只是此表不同
DB 82H,01H,81H,94H,84H,0B4H,0A4H,04H,82H,01H,81H,94H,84H,0C4H,0B4H,04H
DB 82H,01H,81H,0F4H,0D4H,0B4H,0A4H,94H,0E2H,01H,0E1H,0D4H,0B4H,0C4H,0B4H,04H
DB 82H,01H,81H,94H,84H,0B4H,0A4H,04H,82H,01H,81H,94H,84H,0C4H,0B4H,04H
DB 82H,01H,81H,0F4H,0D4H,0B4H,0A4H,94H,0E2H,01H,0E1H,0D4H,0B4H,0C4H,0B4H,04H,00
DB 02H,82H,62H,52H,48H,02H,52H,32H,22H,18H
DB 83H,91H,72H,62H,51H,61H,71H,61H,83H,61H
DB 81H,51H,61H,71H,61H,51H,46H,82H,32H,52H
DB 22H,42H,16H,21H,41H,18H,0E4H,13H,21H,43H
DB 51H,21H,41H,12H,83H,81H,61H,81H,58H,53H
DB 61H,31H,22H,13H,21H,42H,52H,0E2H,42H,21H
DB 11H,91H,41H,18H,63H,81H,32H,52H,21H,41H,
DB 16H,0E4H,11H,21H,31H,51H,26H,11H,21H,43H
DB 51H,82H,62H,52H,61H,51H,42H,21H,11H,0E4H
DB 44H,21H,41H,21H,11H,0E1H,11H,21H,41H,18H
DB 61H,81H,51H,61H,51H,41H,32H,21H,41H,18H
DB 08H,0H,04H ;曲子最後靜音5拍長的時間
DB 00H ;樂曲結束
END
⑶ 單片機怎麼做音樂盒啊
我也在做只是還沒做好下面的程序可以實現放1234567的音 如果換成譜子的話也是可以播放的,只是比較煩 還沒做譜子
ORG 0000H
LJMP MAIN
ORG 001BH
LJMP YINFU
ORG 0030H
MAIN: MOV TMOD,#11H
SETB ET0
SETB ET1
SETB EA
SETB TR0
SETB TR1
MOV R2,#01H
MOV A,#00H
MOV TH1,#00H
MOV TL1,#00H
L0: MOV TL0,R0
MOV TH0,R1
L1: JNB TF0,L1
CPL P1.2
CPL TF0
SJMP L0
YINFU:MOV TH1,#00H
MOV TL1,#00H
DJNZ R2,L2
MOV R2,#64H
MOV R3,A
MOV DPTR,#CDEF
MOVC A,@A+DPTR
MOV R0,A
MOV A,R3
MOV DPTR,#GAB
MOVC A,@A+DPTR
MOV R1,A
MOV A,R3
INC A
L2: CLR TF0
RETI
CDEF: DB 0B2H,0B2H,026H,026H,0DDH,0DDH,008H,008H,01FH,01FH,017H,017H,088H,088H
GAB: DB 0F2H,0F2H,0F4H,0F4H,0F4H,0F4H,0F6H,0F6H,0F7H,0F7H,0F8H,0F8H,0F8H,0F8H
END
⑷ 求一份C51單片機數字音樂盒(LCD1602顯示歌詞,歌詞需與音樂同步)的課程設計。程序為C語言程序的。
蜂鳴器不能唱歌,只會有調子,不知道顯示歌詞有什麼用,
此外,你給的分太少了,我只給你蜂鳴器唱歌的程序,
一個是單純的如何讓蜂鳴器播放音樂,
一個是紅外遙控播放音樂,音樂部分就只在MUSIC.C裡面,你看一下就行了,
樂音是由物體振動發出的,如果你的蜂鳴器的發聲頻率大約等於樂音的頻率,那麼就能發出類似的調子,具體的音符頻率表在我給的PDF的第30頁。
再奉送你一個專門單片機編歌譜曲的軟體。
⑸ 跪求基於51單片機的匯編語言音樂盒程序
OUT BIT P2.3 //該引腳接蜂鳴器
ORG 0000H
LJMP START
ORG 000BH
INC 20H ;中斷服務,中斷計數器加1
MOV TH0,#0D8H
MOV TL0,#0EFH ;12M晶振,形成10毫秒中斷
RETI
START:
MOV SP,#50H
MOV TH0,#0D8H
MOV TL0,#0EFH
MOV TMOD,#01H
MOV IE,#82H
MUSIC0:
NOP
MOV DPTR,#DAT ;表頭地址送DPTR
MOV 20H,#00H ;中斷計數器清0
MOV B,#00H ;表序號清0
MUSIC1:
NOP
CLR A
MOVC A,@A+DPTR ;查表取代碼
JZ END0 ;是00H,則結束
CJNE A,#0FFH,MUSIC5
LJMP MUSIC3
MUSIC5:
NOP
MOV R6,A
INC DPTR
MOV A,B
MOVC A,@A+DPTR ;取節拍代碼送R7
MOV R7,A
SETB TR0 ;啟動計數
MUSIC2:
NOP
CPL OUT
MOV A,R6
MOV R3,A
LCALL DEL
MOV A,R7
CJNE A,20H,MUSIC2 ;中斷計數器(20H)=R7否?
;不等,則繼續循環
MOV 20H,#00H ;等於,則取下一代碼
INC DPTR
; INC B
LJMP MUSIC1
MUSIC3:
NOP
CLR TR0 ;休止100毫秒
MOV R2,#0DH
MUSIC4:
NOP
MOV R3,#0FFH
LCALL DEL
DJNZ R2,MUSIC4
INC DPTR
LJMP MUSIC1
END0:
NOP
MOV R2,#64H ;歌曲結束,延時1秒後繼續
MUSIC6:
MOV R3,#00H
LCALL DEL
DJNZ R2,MUSIC6
LJMP MUSIC0
DEL:
NOP
DEL3:
MOV R4,#02H
DEL4:
NOP
DJNZ R4,DEL4
NOP
DJNZ R3,DEL3
RET
NOP
DAT:
db 26h,20h,20h,20h,20h,20h,26h,10h,20h,10h,20h,80h,26h,20h,30h,20h
db 30h,20h,39h,10h,30h,10h,30h,80h,26h,20h,20h,20h,20h,20h,1ch,20h
db 20h,80h,2bh,20h,26h,20h,20h,20h,2bh,10h,26h,10h,2bh,80h,26h,20h
db 30h,20h,30h,20h,39h,10h,26h,10h,26h,60h,40h,10h,39h,10h,26h,20h
db 30h,20h,30h,20h,39h,10h,26h,10h,26h,80h,26h,20h,2bh,10h,2bh,10h
db 2bh,20h,30h,10h,39h,10h,26h,10h,2bh,10h,2bh,20h,2bh,40h,40h,20h
db 20h,10h,20h,10h,2bh,10h,26h,30h,30h,80h,18h,20h,18h,20h,26h,20h
db 20h,20h,20h,40h,26h,20h,2bh,20h,30h,20h,30h,20h,1ch,20h,20h,20h
db 20h,80h,1ch,20h,1ch,20h,1ch,20h,30h,20h,30h,60h,39h,10h,30h,10h
db 20h,20h,2bh,10h,26h,10h,2bh,10h,26h,10h,26h,10h,2bh,10h,2bh,80h
db 18h,20h,18h,20h,26h,20h,20h,20h,20h,60h,26h,10h,2bh,20h,30h,20h
db 30h,20h,1ch,20h,20h,20h,20h,80h,26h,20h,30h,10h,30h,10h,30h,20h
db 39h,20h,26h,10h,2bh,10h,2bh,20h,2bh,40h,40h,10h,40h,10h,20h,10h
db 20h,10h,2bh,10h,26h,30h,30h,80h,00H
END
⑹ 基於單片機音樂盒的設計
你這個是到網上來找,我就比較呵呵了,既然是畢業設計,就應該到圖書館翻閱資料,我很負責任的說,在圖書館關於音樂盒的單片機設計很多,只要是比較經典的單片機實例的都會有音樂盒,至於模擬,那是最簡單的了,只要你的編程及圖都出來,正確就可以的。
⑺ 基於單片機的音樂盒設計
是MP3的那種嗎
⑻ 基於單片機的音樂播放器的模擬設計外文翻譯
單片機音樂盒,這個讓我想起了我們剛學單片機時做過的一樣東西。
我記得我們原來做課程設計時做過類似的東西
這個模擬我電腦裡面至今還保存著
外文翻譯我覺得簡單啊
不知道你要不要我的幫助呢?
⑼ 用單片機怎麼做音樂盒
那就得用單片機編程!
交通信號燈就是單片機編程出來的!(plc)