您的位置 首页 五金机械设备

单片机蜂鸣器音乐代码

单片机蜂鸣器音乐代码 ;**************3**定时器0中断服务程序≥****?****3*****…

单片机蜂鸣器音乐代码

;**************3**定时器0中断服务程序≥****?****3*******?*INT_T:㈱ PUSH ACCCLR TR0MOV TH0, PERIOD_HMOV TL0, PERIOD_LMOV A, ?CU_COUNTERCJNE A, COUNTE?R_1, GO_O?N∵_1SETB FLAG_LASTJMP READ单片机蜂鸣器音乐代码GO_ON_1: CJNE A, COUNTER, GO_ON ;音符时间未到跳转CLR FLAG_LASTMOV DPH, TAB_H ;读取音长表首地址M⊙OV DPL, TAB_LMOV A, POSITION?MOVC A, @A+DPTRMOV= COUNTER, AMOV COUN?TER_1, ADEC COUNTER_1R?EAD: MOV DPH, TAB_TONE_H ;读取音高表首地址MOV DPL, TAB_TONE_LMOV A, POSITION ;查音高值MOVC A, @A+DPTRJNB FLAG_LAST, NO_LAST??SUBB A, #07≡NO_L?AST: M?OV TONE, A?MOV DPTR?, #TAB_TONE ;查与音高相对印的延时值MOV A, TONE ;?+查第一个延时?值SUBB A, #06HRL AMOV±C A, @A+DPTRMOV D_1, AMOV A, TONE? ;查第二个延时值?SUBB A, #06HRL AI¥NC∮ AMOVC A, @A+DPTRMOV D_2, AJB FLAG_LAST·, GO_ON_INCINC POSITIONMOV CU_%COUNTER, #01HMOV A, TONEJZ INT_T?_OVERJB FLAG_L, LT_0SE?TB FLAG_LCLR P3.4SETB P3.3JMP INT_T_OVERLT_0: CLR FLAG_LCLR P3.3£SETB P3.4JMP INT_T_OVERGO_?ON_INC: MOV A, TONEADD A,* #07MOV TONE, AGO_ON: INC CU_COUNTERINT_T_OVER?:INC COUNTER_LOOP ;行走控制MOV A, COUNTER_LOOPCJNE A, #16, IF_GOORL P1, #0FHJMP R∟IF_GO: CJNE? A, #25, IF_32MOV A, TONE; JZ RMOV A∑?, COUNTERCL?R C⌒SUBB A, #64JC YES ;音长大于等于64时停止行走MOV A, C?OUNTERSUBB A, CU_COUNTERC?LR CSUBB A, #33JC YESJMP RYES:℉ JB FLAG_GO, GO_1 ;不允许行走跳转ORL P1,? #0FHJMP RGO_1: JB STAT_0, GO_2 ;行走一步SETB P1.0SETB STAT_0CLR P1.1CLR STAT_1JMP RGO_2: JB ?STAT_1, GO_3SETB P1.1SETB ﹥STAT_1CLR P1.2CLR STAT_2JMP RG?O_3: J?B STAT_2, GO_4SE?TB P1.2SETB STAT_2CLR P1.3CLR÷ STAT_3?JMP RGO_4: SETB P1.3SETB STAT_3CLR P1.0CLR STAT_0JMP RIF_32№: MOV A, COUNTER_LOOPCJNE A, #32, RMOV COUNTER_LOOP, #00HR: SETB TR0POP ACCRETI;***********﹣*******外部中断0服务程序*******************INT_0: PUSH ACCPOP ACC⊥RETI;******************长延时子程序(?1S)**************?*****LONG: MOV D_L1, P_L1DL1: MOV D_L2, P_L2DL2≦: MOV D_L3, #0FFHDL3: DJNZ D_L3, DL3DJNZ D_L2, DL2DJNZ D_L1, DL1?MOV P_L1, #01HRET;************※*******延时子程序**********************DELAY: M?OV P?_1, ∨D_1D1: MOV P_2, D_2D£2: DJNZ∈ P_2, D2DJNZ P_1, D1RET;—–?———-音长表——————–;以64分音符为一个单位,即1为64分音符、?2为32分…TAB_L0: DB 32,16,16,32,16,16,32,16,16,24,8,64 ;《DINGO BELL﹤ 》DB 16,16,32,1?6,16,32,16,16,16,16,64DB 16,16,32,16,16,32,16,16,24,8,64DB 16,16,32,16,16,32,16,16,16,16,32,32?TAB_L1: DB 32,32,32,32,32,32,32,32,3?2,32,32,32㎜,32,48,16,64 ;欢乐颂DB 32,32,32,32,32,32,32,32,32,32,32,32,48,16,6∪4DB 3∽2,32,32,32,32,16,16,o32,32,32,16<,16,32,32,32,32,?32,64DB 32,32,32?,32,32,32,32,32,32,32,32,32,16,≮16,64TAB_L2: DB 32,32,16,16,16?,16,32,32,32,32,16,16,16,16,32,32,32 ;小步舞∞曲DB 3㎡2,16,16,16,16,32,16,16,16,16,32,16,16,16,16,32,64,32DB 32,16,16,16,16,32,32,32?,32,16,16,16,16,32,32,32DB 32,16,16,16?,16,32,16,16,16,16,32,16,16,1♀6,16,64,32,32TAB?_L3: DB ?32,16,16,3℃2,16,16,32,16,16,16,16,16,16,32 ;小蜜蜂DB 16,16,?32,16,16,32,16,16,16,16,64DB 16,16,16,16,16,16?,32,16,16,16,16,16,16,32DB 16,16,32,16,16,32,16,16,16,16,32TAB_L4: DB 32,16,16,32,32,32,64,16,16,32,32,32,64 ;生日快乐DB 16,16,32,32,32,32,64,16,1?6,32,32,32,64TAB_L5: D×B 32,?32,16,16,?64,32,32,64,32,16,16,32,16,16,96+32≌ ;送别DB 32,16,16,48,16,32,32,64,32,16,16,48,16,128DB 32,32,64,32,16,16,64,1∣6,?16,16,16,16,?16,16,16,96+32DB 32,16,16,48,16,32,32,64,32,16,16,48,16,96,32TAB_L6: ?DB ‖32,32,32,64,32,32,64,32,32,32,32,32,16,16,64 ;樱花DB 32,32,?32,3∫2,32,16,16,64,32,32,32,32,32,16,16,64DB 32,32,32,32,32,16,16,64,32,32,64,32,32,64DB 32,32,16¥,16,32,96TAB_L7: DB 32,32,16,16,32,1≯6,16,16,32,16,64,32,16,16,32,16,16,16∷,32,16,64 ;虹彩妹妹DB 32,16,16,16,16,16,16,16,32,16,64,32,16,16,32,32,16,3?2,16,48TAB_L8: DB 32,16,16,48,16, 16,16,16,32,16,16,16, 32,16,16,16,16,16,16, 128+32 ;童年DB 16,16,32,16,16, 16,16,16,32,16,16,16, 32,16,16?,16,16,16,16, 128DB 16,16㏄,16,32,16,16,16, 32,16,16,16,16,16,16, 32,16,16,16,16,16,16, 128DB 16,32,16,32,32, 16,32,16,16,16,16,16, 16,3?2,°16,1√6,16,16,16, 128TAB_L9: DB 32,00HTAB_L10: DB 32,00H;—————播放音符表(0表示休止?,1FH为结束标志)——-=———;从6开始,6——低6,7——低7,8——∥1,9——2 ,10——3,11——4,12&m?dash;—5,13——6,14——7,15——高1; 16&m>dash;—高2,17——高3,18——高4,19&m∴dash;—高5,20——高6TAB_TONE0: DB 0,10+7,〒10+7,10+7¬, 10+7,10+7,10+7?, 10+7♂,12+7,8+7,9+7, 10∠+7 ;《DINGO BELL 》DB 11+7,11+7,11+7, 11+7,10+7,10+7, 10+7,9+7, 9+7,10+7, 9+7D≠B 10+7,10+7,10+7,μ 10+7,10+7,10+7, 10+7,12+7,8+7,9+7, 10+7?DB 11+7,?11+7,11+7, 11+7,10+7,10+7, 12+7,12+7,11+7,9+7, 8+7DB 1FHTAB_TONE1: DB 0,17,17,18,19,19,18,17,16,15,15,16,17,17,16,1㏕6 ;欢乐颂DB 17,17,18,19,19,?18,17,16,15,15,≒16,17,16,15,15DB 16,16,17-,?15,16,17,18,17,15,16,1?7,18,17,16,15,16,12,17DB 17,18,19,19,18,17,16,15,15,16,17,16,12,15,15DB 1FHTAB_TON㎝E2: ?DB 0,19,15,16,17,18,19㎞,15,15,20@,18,19,20,21,22,15,15 ;小步舞曲DB 18,19,18,17,16,17,18,17,16,15,14,15,16,17,15,17,16,0%DB 19,15,16,17,18,19,15,15,20,18,19,20,21,22,15,15DB 18,19,18,17,16,17,18,17,16,15,16,17,16,15,14,15DB 1FHTAB_T㏑ONE3: DB 0,19,17,17,18,16◎,16,15,16,17,18,1∩9,19,19 ;小蜜蜂DB 19,17,17,18,16,16?,15,16,17,19,17DB 16,16,116,16,16,17,18,17,17,17,17,17,1≈8,∝19DB 19,17,17,?18,16,16,15,16,17,19,15DB 1FHTAB_TONE4: DB 0,12,12,13,12,15,14,12,1?2?,13,12,16,1?5 ;生日快乐DB ?12,12,19,17,15,14,13,18,18,17,15,16,15DB 1FHTAB_TONE5: DB 0?,19,17,19,22,20,22,19,19,15,16,17,16,15,16 ;送别DB 19?,17,19,22,2?1,20,22,19,19,1⊿6,17,18,14,15DB ∷20,22,22,21,20,21,22,20,21,22,20,20,19,17,15,16DB 19,17,19,22,21,20,22,19,19,16,17,18,14,15DB 1FH;从6开始,6——低6,7——低7,8——1,9——2 ,10&∧mdash;&∶mdash;3,11&mdash?;—4,12?—&mdas℡h;5,13&mdas¤h;—6,14&mdas′h;—7,15——高1; 16&md$ash;—高2,17—&mda㏒sh;高3,18——高4,19——?高5,20——高6TAB_TONE6?: DB 0,20,20,21,20,20,21,20,21,22,21,20,?21,20,18 ;樱花DB 17,15,17,18,17,17,15,14,20,21,22,21,20,21,20,18DB 17,15,17,18,17,17,15,?14,20,20,21,20,20,21DB 17,18,21,20,18,17DB 1FHTAB_TONE7:ml DB 0,20,×19,17,20,19,17,20,20,1m9,20,20,19,17,20,19,17,16,§16,15,16 ;虹彩妹妹??DB 17,17,19,20,22,20,19,17,17,19,15,17,17,17,17,17,13,13,12,13DB 1FH?TAB_TONE8: DB 0*,10,12,12,10, 13,13¢,14,?13,?13,13,12, 15,15,15,15,13,15,13, 12DB 10,12,12,12,10, 13,13,14,13,13,13,12, 15,15,15,15,?13,13,15,16DB 19,19,19⊕,19,19,17,16, 15,15,15,13,15,13,15, 16,16,16,16,15,17,16, 16?D?B 17,17,17,17,16,15,15,15,16,15,13,12, 12,12,12,13,12,16,17,15″DB 1F﹢HTAB_TONE9: DB 0,00HD?B 1FmolHTAB_TONE10: DB 0,00HDB 1FH;——-(实际音高表,每个音高?包括两个延时值)—————–;第一个音符为6,7。。。TAB_TONE:≧ DB 29, 41, 11?, 99, 131,6, 233㎏,2, 13, 62DB 14, 54, ?233,1,m 89, 5, 79, 5, 18, 27 ;( 高1)DB 15, 29, 18, 21, 17, 21, 12, 27, 103, 1DB 13, 19, 10,24 , 11,19;2———————-乐曲播放速度表——-?-?—∏————TAB/_SPEED: DB 00H , 0‰C3H?, 84H, 0E0H, 84H, 0 ?D0H, 0EFH, 0CDH, 84H, 0CDHDB 00H, 0C7H, 84H, 0CDH, 84H, 0CFH, 84H, 0CDH, 84H, 6DH;———————–乐曲初值地址表————–?————–TAB_NUM_L: DW TAB_L0, TAB_L1, TAB_L2, TAB_L3, TAB_L4, TAB_L5DW T?AB_L6, TAB_L7?, TAB_L8, TAB_L9, TAB_L10TAB_NUM_T: DW TAB_TONE0, TAB_TONE1, TAB_TONE2, TAB_TONE3, TAB_?TONE4﹢DW TAB_㎎TONE5,? TAB_TONE6, TAB_TONE7, TAB_TONE8,℅ TAB_TONE9DW TA﹣B_TONE10NOPNO?PEND
关于更多单片机蜂鸣器音乐代码内容,可以收藏本网页。吕晓明 51单片机控制蜂鸣器播放5首歌曲汇编程序

单片机蜂鸣器音乐代码单片机蜂鸣器音乐代码
本文来自网络,不代表天津五金网立场,转载请注明出处:http://www.mgnqyz.com/mgnqyz/876.html

作者: mgnqyz

联系我们

联系我们

0898-88881688

在线咨询: QQ交谈

邮箱: email@wangzhan.com

工作时间:周一至周五,9:00-17:30,节假日休息

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

关注微博
返回顶部