Ⅰ 跪求基于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
Ⅱ 求51单片机 数字音乐盒 汇编语言代码
Z8279
EQU
8701H
D8279
EQU
8700H
LO
EQU
30H
HI
EQU
31H
ORG
0000H
AJMP
START
ORG
000BH
LJMP
T0_INT
START:
MOV
SP,#60H
MOV
P3,#0FFH
MOV
TMOD,#00000000B
MOV
IE,#10000010B
LCALL
F8279
;;8279的初始化
LCALL
LO_KEY
;;判断是否有下压键
PAN1:
MOV
DPTR,Z8279
MOVX
A,@DPTR
ANL
A,#3FH
MOV
R2,A
;
;保存键值
ANL
A,#01H
;;键值1
JNZ
S_1
JZ
P_1
S_1:
LCALL
SONG_1
P_1:
MOV
A,R2
ANL
A,#02H
;;键值2
JNZ
S_2
JZ
P_2
S_2:
LCALL
SONG_2
P_2
MOV
A,R2
ANL
A,#03H
;;键值3
JNZ
S_3
JZ
P_3
S_3:
LCALL
SONG_3
P_3
MOV
A,R2
ANL
A,#04H
;;键值4
JNZ
S_4
JZ
P_4
S_4
LCALL
SONG_4
P_4
MOV
A,R2
ANL
A,#05H
;;键值5
JNZ
S_5
JZ
PAN1
S_5:
LCALL
SONG_5
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
SONG_1:
;//歌曲1
MOV
R4,#15
LOOP1:
LCALL
VALUE1
SETB
TR0
MOV
R5,#20
LCALL
DELAY
CLR
TR0
MOV
R5,#20
LCALL
DELAY
LCALL
P_KEY
DJNZ
R4,LOOP1
LCALL
SONG_2
RET
SONG_2:
;//歌曲2
MOV
R4,#15
LOOP2:
LCALL
VALUE1
SETB
TR0
MOV
R5,#20
LCALL
DELAY
CLR
TR0
MOV
R5,#20
LCALL
DELAY
LCALL
P_KEY
DJNZ
R4,LOOP2
LCALL
SONG_3
RET
SONG_3:
;//歌曲3
MOV
R4,#15
LOOP3:
LCALL
VALUE1
SETB
TR0
MOV
R5,#20
LCALL
DELAY
CLR
TR0
MOV
R5,#20
LCALL
DELAY
LCALL
P_KEY
DJNZ
R4,LOOP3
LCALL
SONG_4
RET
SONG_4:
;//歌曲4
MOV
R4,#15
LOOP4:
LCALL
VALUE1
SETB
TR0
MOV
R5,#20
LCALL
DELAY
CLR
TR0
MOV
R5,#20
LCALL
DELAY
LCALL
P_KEY
DJNZ
R4,LOOP4
LCALL
SONG_5
RET
SONG_5:
;//歌曲5
MOV
R4,#15
LOOP5:
LCALL
VALUE1
SETB
TR0
MOV
R5,#20
LCALL
DELAY
CLR
TR0
MOV
R5,#20
LCALL
DELAY
LCALL
P_KEY
DJNZ
R4,LOOP5
LCALL
SONG_1
RET
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
VALUE1:
;//歌曲1的频率设置
MOV
DPTR,#FREH1
MOV
A,R4
MOVC
A,@A+DPTR
MOV
HI,A
MOV
DPTR,#FREL1
MOV
A,R4
MOVC
A,@A+DPTR
MOV
LO,A
MOV
R4,#1*****************************************
RET
VALUE2:
;/;/歌曲2的频率设置
MOV
DPTR,#FREH2
MOV
A,R4
MOVC
A,@A+DPTR
MOV
HI,A
MOV
DPTR,#FREL2
MOV
A,R4
MOVC
A,@A+DPTR
MOV
LO,A
MOV
R4,#1
RET
VALUE3:
;//歌曲3的频率设置
MOV
DPTR,#FREH3
MOV
A,R4
MOVC
A,@A+DPTR
MOV
HI,A
MOV
DPTR,#FREL3
MOV
A,R4
MOVC
A,@A+DPTR
MOV
LO,A
MOV
R4,#1
RET
VALUE4:
;//歌曲4的频率设置
MOV
DPTR,#FREH4
MOV
A,R4
MOVC
A,@A+DPTR
MOV
HI,A
MOV
DPTR,#FREL4
MOV
A,R4
MOVC
A,@A+DPTR
MOV
LO,A
MOV
R4,#1
RET
VALUE5:
;//歌曲5的频率设置
MOV
DPTR,#FREH5
MOV
A,R4
MOVC
A,@A+DPTR
MOV
HI,A
MOV
DPTR,#FREL5
MOV
A,R4
MOVC
A,@A+DPTR
MOV
LO,A
MOV
R4,#1
RET
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
T0_INT:
MOV
TL0,LO
MOV
TH0,HI
CPL
P3.4
RETI
DELAY:
MOV
R6,#50
D1:
MOV
R7,#100
DJNZ
R7,$
DJNZ
R6,D1
DJNZ
R5,DELAY
RET
F8279:
MOV
DPTR,Z8279
MOV
A,#10H
MOVX
@DPTR,A
MOV
A,#34H
MOVX
@DPTR,A
MOV
A,#0D1H
MOVX
@DPTR,A
LCALL
DELAY
MOV
A,#80H
MOVX
@DPTR,A
MOV
A,#40H
MOVX
@DPTR,A
RET
LO_KEY:
MOV
DPTR,Z8279
MOVX
A,@DPTR
ANL
A,#0FH
JZ
LO_KEY
RET
P_KEY:
MOV
DPTR,Z8279
MOVX
A,@DPTR
ANL
A,#0FH
JNZ
SIGN1
JZ
SIGN2
SIGN1:
LJMP
PAN1
SIGN2:
RET
FREH1
DB
0,226,229,232,233,236,238,240,241,242,244,244,246,247,248
FREL1
DB
0,4,13,10,20,3,8,6,2,23,5,26,1,4,3
FREH2
DB
0,236,229,232,233,226,230,240,231,246,244,234,236,247,248
FREL2
DB
0,4,13,10,20,3,8,6,2,23,5,26,1,4,3
FREH3
DB
0,226,229,232,233,236,238,240,241,242,244,244,246,247,248
FREL3
DB
0,4,13,10,20,3,8,6,2,23,5,26,1,4,3
FREH4
DB
0,226,229,232,233,236,238,240,241,242,244,244,246,247,248
FREL4
DB
0,4,13,10,20,3,8,6,2,23,5,26,1,4,3
FREH5
DB
0,226,229,232,233,236,238,240,241,242,244,244,246,247,248
FREL5
DB
0,4,13,10,20,3,8,6,2,23,5,26,1,4,3
END
Ⅲ 求一份C51单片机数字音乐盒(LCD1602显示歌词,歌词需与音乐同步)的课程设计。程序为C语言程序的。
蜂鸣器不能唱歌,只会有调子,不知道显示歌词有什么用,
此外,你给的分太少了,我只给你蜂鸣器唱歌的程序,
一个是单纯的如何让蜂鸣器播放音乐,
一个是红外遥控播放音乐,音乐部分就只在MUSIC.C里面,你看一下就行了,
乐音是由物体振动发出的,如果你的蜂鸣器的发声频率大约等于乐音的频率,那么就能发出类似的调子,具体的音符频率表在我给的PDF的第30页。
再奉送你一个专门单片机编歌谱曲的软件。