单片机at89c51制作歌曲曲谱_AT89c51单片机音乐程序
用c语言在单片机AT89C51编写音乐程序,求程序,求求你们了
下面是一段个完整的程序,有两首歌曲编码,看看可以吗?
#include "reg52.h"
unsigned char Count;
sbit _Speak =P2^3 ; //讯响器控制脚
unsigned char code SONG[] ={ //祝你平安
0x26,0x20,0x20,0x20,0x20,0x20,0x26,0x10,0x20,0x10,0x20,0x80,0x26,0x20,0x30,0x20,
0x30,0x20,0x39,0x10,0x30,0x10,0x30,0x80,0x26,0x20,0x20,0x20,0x20,0x20,0x1c,0x20,
0x20,0x80,0x2b,0x20,0x26,0x20,0x20,0x20,0x2b,0x10,0x26,0x10,0x2b,0x80,0x26,0x20,
0x30,0x20,0x30,0x20,0x39,0x10,0x26,0x10,0x26,0x60,0x40,0x10,0x39,0x10,0x26,0x20,
0x30,0x20,0x30,0x20,0x39,0x10,0x26,0x10,0x26,0x80,0x26,0x20,0x2b,0x10,0x2b,0x10,
0x2b,0x20,0x30,0x10,0x39,0x10,0x26,0x10,0x2b,0x10,0x2b,0x20,0x2b,0x40,0x40,0x20,
0x20,0x10,0x20,0x10,0x2b,0x10,0x26,0x30,0x30,0x80,0x18,0x20,0x18,0x20,0x26,0x20,
0x20,0x20,0x20,0x40,0x26,0x20,0x2b,0x20,0x30,0x20,0x30,0x20,0x1c,0x20,0x20,0x20,
0x20,0x80,0x1c,0x20,0x1c,0x20,0x1c,0x20,0x30,0x20,0x30,0x60,0x39,0x10,0x30,0x10,
0x20,0x20,0x2b,0x10,0x26,0x10,0x2b,0x10,0x26,0x10,0x26,0x10,0x2b,0x10,0x2b,0x80,
0x18,0x20,0x18,0x20,0x26,0x20,0x20,0x20,0x20,0x60,0x26,0x10,0x2b,0x20,0x30,0x20,
0x30,0x20,0x1c,0x20,0x20,0x20,0x20,0x80,0x26,0x20,0x30,0x10,0x30,0x10,0x30,0x20,
0x39,0x20,0x26,0x10,0x2b,0x10,0x2b,0x20,0x2b,0x40,0x40,0x10,0x40,0x10,0x20,0x10,
0x20,0x10,0x2b,0x10,0x26,0x30,0x30,0x80,0x00,
//路边的野华不要采
0x30,0x1C,0x10,0x20,0x40,0x1C,0x10,0x18,0x10,0x20,0x10,0x1C,0x10,0x18,0x40,0x1C,
0x20,0x20,0x20,0x1C,0x20,0x18,0x20,0x20,0x80,0xFF,0x20,0x30,0x1C,0x10,0x18,0x20,
0x15,0x20,0x1C,0x20,0x20,0x20,0x26,0x40,0x20,0x20,0x2B,0x20,0x26,0x20,0x20,0x20,
0x30,0x80,0xFF,0x20,0x20,0x1C,0x10,0x18,0x10,0x20,0x20,0x26,0x20,0x2B,0x20,0x30,
0x20,0x2B,0x40,0x20,0x20,0x1C,0x10,0x18,0x10,0x20,0x20,0x26,0x20,0x2B,0x20,0x30,
0x20,0x2B,0x40,0x20,0x30,0x1C,0x10,0x18,0x20,0x15,0x20,0x1C,0x20,0x20,0x20,0x26,
0x40,0x20,0x20,0x2B,0x20,0x26,0x20,0x20,0x20,0x30,0x80,0x20,0x30,0x1C,0x10,0x20,
0x10,0x1C,0x10,0x20,0x20,0x26,0x20,0x2B,0x20,0x30,0x20,0x2B,0x40,0x20,0x15,0x1F,
0x05,0x20,0x10,0x1C,0x10,0x20,0x20,0x26,0x20,0x2B,0x20,0x30,0x20,0x2B,0x40,0x20,
0x30,0x1C,0x10,0x18,0x20,0x15,0x20,0x1C,0x20,0x20,0x20,0x26,0x40,0x20,0x20,0x2B,
0x20,0x26,0x20,0x20,0x20,0x30,0x30,0x20,0x30,0x1C,0x10,0x18,0x40,0x1C,0x20,0x20,
0x20,0x26,0x40,0x13,0x60,0x18,0x20,0x15,0x40,0x13,0x40,0x18,0x80,0x00,
};
void Time0_Init()
{
TMOD = 0x01;
IE = 0x82;
TH0 = 0xD8;
TL0 = 0xEF; //12MZ晶振,10ms
}
void Time0_Int() interrupt 1
{
TH0 = 0xD8;
TL0 = 0xEF;
Count++; //长度加1
}
/*-------------------------------------------------
功能:1MS延时子程序
-------------------------------------------------*/
void Delay_xMs(unsigned int x)
{
unsigned int i,j;
for( i =0;i < x;i++ )
{
for( j =0;j<3;j++ );
}
}
/*-------------------------------------------------
功能:歌曲播放子程序i为播放哪一段曲目
-------------------------------------------------*/
void Play_Song(unsigned char i)
{
unsigned char Temp1,Temp2;
unsigned int Addr;
Count = 0; //中断计数器清0
Addr = i * 217;
while(1)
{
Temp1 = SONG[Addr++];
if ( Temp1 == 0xFF ) //休止符
{
TR0 = 0;
Delay_xMs(100);
}
else if ( Temp1 == 0x00 ) //歌曲结束符
{
return;
}
else
{
Temp2 = SONG[Addr++];
TR0 = 1;
while(1)
{
_Speak = ~_Speak;
Delay_xMs(Temp1);
if ( Temp2 == Count )
{
Count = 0;
break;
}
}
}
}
}
/*-------------------------------------------------
功能:主程序
-------------------------------------------------*/
void main()
{
Time0_Init(); //定时器0中断初始化
while(1)
{
Play_Song(0); //播放
}
}
用c语言在单片机AT89C51编写音乐程序
谁给你的程序啊,把你的程序贴出来看看。
急急急!!! 求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
基于AT89c51的单片机的音乐盒设计
//《世上只有妈妈好》51单片机C语言程序和音乐采灯程序
//2007-5-22 作者:徐学军
//此程序在硬件上调试通过
//本程序的单片机晶振采用11.0592MHZ
//此程序的流水灯随音乐的节拍的快慢而动
#include
sbit speaker=P2^0;
unsigned char timer0h,timer0l,time,led=1,j=0;
unsigned char flagd=0;
//世上只有妈妈好数据表
code unsigned char sszymmh[]={ 6,2,3, 5,2,1, 3,2,2, 5,2,2, 1,3,2, 6,2,1, 5,2,1,
6,2,4, 3,2,2, 5,2,1, 6,2,1, 5,2,2, 3,2,2, 1,2,1,
6,1,1, 5,2,1, 3,2,1, 2,2,4, 2,2,3, 3,2,1, 5,2,2,
5,2,1, 6,2,1, 3,2,2, 2,2,2, 1,2,4, 5,2,3, 3,2,1,
2,2,1, 1,2,1, 6,1,1, 1,2,1, 5,1,6, 0,0,0
} ;
// 音阶频率表 高八位
code unsigned char FREQH[]={
0xF2,0xF3,0xF5,0xF5,0xF6,0xF7,0xF8,
0xF9,0xF9,0xFA,0xFA,0xFB,0xFB,0xFC,0xFC, //1,2,3,4,5,6,7,8,i
0xFC,0xFD,0xFD,0xFD,0xFD,0xFE,
0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFF,
} ;
// 音阶频率表 低八位
code unsigned char FREQL[]={
0x42,0xC1,0x17,0xB6,0xD0,0xD1,0xB6,
0x21,0xE1,0x8C,0xD8,0x68,0xE9,0x5B,0x8F, //1,2,3,4,5,6,7,8,i
0xEE,0x44, 0x6B,0xB4,0xF4,0x2D,
0x47,0x77,0xA2,0xB6,0xDA,0xFA,0x16,
};
void delay(unsigned char t)
{
unsigned char t1;
unsigned long t2;
for(t1=0;t1<t;t1++)
{
for(t2=0;t2<8000;t2++)
{
;
}
}
TR0=0;
}
void t0int() interrupt 1
{
TR0=0;
speaker=!speaker;
TH0=timer0h;
TL0=timer0l;
TR0=1;
}
void song()
{
TH0=timer0h;
TL0=timer0l;
TR0=1;
delay(time);
}
void main(void)
{
unsigned char k,i;
TMOD=1; //置CT0定时工作方式1
EA=1;ET0=1;//IE=0x82 //CPU开中断,CT0开中断
while(1)
{
i=0;
time=1;
while(time)
{
if(j==8)
{
//led=1;
j=0;flagd=~flagd;
if(flagd)
{
led=0x80;
}
else
{
led=1;
}
}
else
{
P1=~led;
if(flagd)
{
led=led>>1;
}
else
{
led=led<<1;
}
j++;
}
k=sszymmh[i]+7*sszymmh[i+1]-1;
timer0h=FREQH[k];
timer0l=FREQL[k];
time=sszymmh[i+2];
i=i+3;
song();
}
}
}
基于AT89C51单片机控制的多功能带音乐跑马灯的设计 求大神帮忙解决!
20分财富,让人帮你写这么长的程序?程序就是长,但是不难。很简单。
热门曲谱
- 渡情笛子曲谱
曲谱自学网今天精心准备的曲谱是《渡情笛子曲谱》,下面是详解!
竹笛 我想学 渡情 请问是买A还是B调 的笛子 我还要...
竹笛的调和...
[详情]分类:曲谱大全时间:07:36 - c调口琴曲谱
曲谱自学网今天精心准备的曲谱是《c调口琴曲谱》,下面是详解!
求c调24孔口琴简谱大全
小弟求c调24孔口琴简谱大全,邮箱:zifuchen@st...
[详情]分类:曲谱大全时间:07:36 - 徳德玛歌曲谱
曲谱自学网今天精心准备的曲谱是《徳德玛歌曲谱》,下面是详解!
德德玛歌曲
1. 草原母亲河
[详情]分类:曲谱大全时间:07:36
2. 蓝蓝的马莲花
3. 阿妈的... - 京剧青衣曲谱
曲谱自学网今天精心准备的曲谱是《京剧青衣曲谱》,下面是详解!
京剧老旦唱段曲谱 与琴谱有什么区别
两者均属旦行。旦行包括:青...
[详情]分类:曲谱大全时间:07:35 - 诺言钢琴曲谱
曲谱自学网今天精心准备的曲谱是《诺言钢琴曲谱》,下面是详解!
洛洛历险记的片尾曲诺言的钢琴简谱(最好有前奏)
偶然听见这首歌觉得...
[详情]分类:曲谱大全时间:07:34 - 流行口琴曲谱
曲谱自学网今天精心准备的曲谱是《流行口琴曲谱》,下面是详解!
适合初学者的口琴简谱,要流行音乐的
我把爱铺成蓝天 ...
[详情]分类:曲谱大全时间:07:35 - 又见山里红曲谱
曲谱自学网今天精心准备的曲谱是《又见山里红曲谱》,下面是详解!
又见山里红简谱
分类:曲谱大全时间:07:31 - 钢琴流行曲谱
曲谱自学网今天精心准备的曲谱是《钢琴流行曲谱》,下面是详解!
有没有流行歌曲的钢琴简谱
樱花草,老人与海,爱转角等。谢谢。本人急...
[详情]分类:曲谱大全时间:07:29 - 古筝乡韵曲谱
曲谱自学网今天精心准备的曲谱是《古筝乡韵曲谱》,下面是详解!
古筝 乡韵
乡韵多难?既然云裳诉是它改的,乡韵应该也很难吧,特长生...
[详情]分类:曲谱大全时间:07:27 - 初学古琴曲谱
曲谱自学网今天精心准备的曲谱是《初学古琴曲谱》,下面是详解!
请问初学者如何识古琴谱,对谱怎么弹?
减字谱:
[详情]分类:曲谱大全时间:07:27
识谱还是比... - 一生无悔曲谱
曲谱自学网今天精心准备的曲谱是《一生无悔曲谱》,下面是详解!
基督教歌曲为福音一生无悔谱
基督教歌曲为福音一生无悔谱...
...[详情]分类:曲谱大全时间:07:26 - 手机曲谱软件
曲谱自学网今天精心准备的曲谱是《手机曲谱软件》,下面是详解!
在手机上怎么制作谱子
没试过用手机做谱子,效率太低了…
[详情]分类:曲谱大全时间:07:22
建... - 渴望主题曲谱
曲谱自学网今天精心准备的曲谱是《渴望主题曲谱》,下面是详解!
渴望的简谱
《渴望》的简谱是电视剧《渴望》录制的同名主题曲...
[详情]分类:曲谱大全时间:07:22 - 乐伶曲谱在哪
曲谱自学网今天精心准备的曲谱是《乐伶曲谱在哪》,下面是详解!
天涯明月刀ol乐伶曲谱怎么获得
首先你要学会第一职业 第二行里面...
[详情]分类:曲谱大全时间:07:21 - 天刀童话曲谱
曲谱自学网今天精心准备的曲谱是《天刀童话曲谱》,下面是详解!
天涯明月刀ol文士曲谱有哪些
笛曲·水云游 由身份技能点...
[详情]分类:曲谱大全时间:07:20 - 天刀曲谱弹琴
曲谱自学网今天精心准备的曲谱是《天刀曲谱弹琴》,下面是详解!
天涯明月刀乐伶怎么弹琴给别人加BUF
1:要想加BUF,首先游戏中...
[详情]分类:曲谱大全时间:07:20 - 天竺少女曲谱
曲谱自学网今天精心准备的曲谱是《天竺少女曲谱》,下面是详解!
天竺少女的古筝谱
- 绿岛小夜曲曲谱
曲谱自学网今天精心准备的曲谱是《绿岛小夜曲曲谱》,下面是详解!
绿岛小夜曲原唱晋秦歌词和谱曲
绿岛小夜曲原唱晋秦歌词和谱曲...[详情]
分类:曲谱大全时间:07:17 - 越剧曲谱下载
曲谱自学网今天精心准备的曲谱是《越剧曲谱下载》,下面是详解!
求越剧简谱
吴凤花的《狸猫换太子》拷寇部分,三次举起无情棒的曲谱,...
[详情]分类:曲谱大全时间:07:13 - 萨克斯曲谱简谱
曲谱自学网今天精心准备的曲谱是《萨克斯曲谱简谱》,下面是详解!
学萨克斯要学五线谱还是简谱
学萨克斯必须学五线谱。
[详情]分类:曲谱大全时间:07:37
其实...