...要求在里面,谢谢了,帮个忙,可以追加财富值!
发布网友
发布时间:2024-09-30 12:30
我来回答
共4个回答
热心网友
时间:2024-10-13 10:43
#include <REG52.H>
#include "SoundPlay.h"
void Delay1ms(unsigned int count)
{
unsigned int i,j;
for(i=0;i<count;i++)
for(j=0;j<120;j++);
}
//*****************************Music******************************************************
unsigned char code Music_Girl[]={ 0x17,0x02, 0x17,0x03, 0x18,0x03, 0x19,0x02, 0x15,0x03,
0x16,0x03, 0x17,0x03, 0x17,0x03, 0x17,0x03, 0x18,0x03,
0x19,0x02, 0x16,0x03, 0x17,0x03, 0x18,0x02, 0x18,0x03,
0x17,0x03, 0x15,0x02, 0x18,0x03, 0x17,0x03, 0x18,0x02,
0x10,0x03, 0x15,0x03, 0x16,0x02, 0x15,0x03, 0x16,0x03,
0x17,0x02, 0x17,0x03, 0x18,0x03, 0x19,0x02, 0x1A,0x03,
0x1B,0x03, 0x1F,0x03, 0x1F,0x03, 0x17,0x03, 0x18,0x03,
0x19,0x02, 0x16,0x03, 0x17,0x03, 0x18,0x03, 0x17,0x03,
0x18,0x03, 0x1F,0x03, 0x1F,0x02, 0x16,0x03, 0x17,0x03,
0x18,0x03, 0x17,0x03, 0x18,0x03, 0x20,0x03, 0x20,0x02,
0x1F,0x03, 0x1B,0x03, 0x1F,0x66, 0x20,0x03, 0x21,0x03,
0x20,0x03, 0x1F,0x03, 0x1B,0x03, 0x1F,0x66, 0x1F,0x03,
0x1B,0x03, 0x19,0x03, 0x19,0x03, 0x15,0x03, 0x1A,0x66,
0x1A,0x03, 0x19,0x03, 0x15,0x03, 0x15,0x03, 0x17,0x03,
0x16,0x66, 0x17,0x04, 0x18,0x04, 0x18,0x03, 0x19,0x03,
0x1F,0x03, 0x1B,0x03, 0x1F,0x66, 0x20,0x03, 0x21,0x03,
0x20,0x03, 0x1F,0x03, 0x1B,0x03, 0x1F,0x66, 0x1F,0x03,
0x1B,0x03, 0x19,0x03, 0x19,0x03, 0x15,0x03, 0x1A,0x66,
0x1A,0x03, 0x19,0x03, 0x19,0x03, 0x1F,0x03, 0x1B,0x03,
0x1F,0x00, 0x1A,0x03, 0x1A,0x03, 0x1A,0x03, 0x1B,0x03,
0x1B,0x03, 0x1A,0x03, 0x19,0x03, 0x19,0x02, 0x17,0x03,
0x15,0x17, 0x15,0x03, 0x16,0x03, 0x17,0x03, 0x18,0x03,
0x17,0x04, 0x18,0x0E, 0x18,0x03, 0x17,0x04, 0x18,0x0E,
0x18,0x66, 0x17,0x03, 0x18,0x03, 0x17,0x03, 0x18,0x03,
0x20,0x03, 0x20,0x02, 0x1F,0x03, 0x1B,0x03, 0x1F,0x66,
0x20,0x03, 0x21,0x03, 0x20,0x03, 0x1F,0x03, 0x1B,0x03,
0x1F,0x66, 0x1F,0x04, 0x1B,0x0E, 0x1B,0x03, 0x19,0x03,
0x19,0x03, 0x15,0x03, 0x1A,0x66, 0x1A,0x03, 0x19,0x03,
0x15,0x03, 0x15,0x03, 0x17,0x03, 0x16,0x66, 0x17,0x04,
0x18,0x04, 0x18,0x03, 0x19,0x03, 0x1F,0x03, 0x1B,0x03,
0x1F,0x66, 0x20,0x03, 0x21,0x03, 0x20,0x03, 0x1F,0x03,
0x1B,0x03, 0x1F,0x66, 0x1F,0x03, 0x1B,0x03, 0x19,0x03,
0x19,0x03, 0x15,0x03, 0x1A,0x66, 0x1A,0x03, 0x19,0x03,
0x19,0x03, 0x1F,0x03, 0x1B,0x03, 0x1F,0x00, 0x18,0x02,
0x18,0x03, 0x1A,0x03, 0x19,0x0D, 0x15,0x03,0x15,0x02, 0x18,0x66,0x16,0x02,0x17,0x02,0x15,0x00,0x00,0x00}; main()
{
InitialSound();
while(1)
{
Play(Music_Girl,0,3,360);
Delay1ms(500);
Play(Music_Same,0,3,360);
Delay1ms(500);
Play(Music_Two,0,3,360);
Delay1ms(500);
}
}
热心网友
时间:2024-10-13 10:48
#include"reg52.h"
#define uchar unsigned char
#define uint unsigned int
void sdelay(uchar t);
uchar key_music();
void timeinit();
uint key,time;
uchar temp;
uchar SH0,SL0;
uint code tab[]={64021,64103,64260,64400,64524,64580,64684,64777,
64820,64898,64968,65030,65,58,65110,65157,65178};
sbit speaker=P1^0;
sbit P24=P2^4;
sbit P25=P2^5;
sbit P26=P2^6;
sbit P27=P2^7;
void main()
{
timeinit();
while(1)
{
key_music();
// if(key)
}
}
uchar key_music()
{
P2=0XFF;
P24=0;
temp=P2;
temp=temp&0x0f;
if(temp==0x0f)
speaker=0;
if(temp!=0x0f)
{
sdelay(5);
temp=P2;
temp=temp&0x0f;
if(temp!=0x0f)
{
temp=P2;
temp=temp&0x0f;
switch(temp)
{
case 0x0e: key=0; break;
case 0x0d: key=1; break;
case 0x0b: key=2; break;
case 0x07: key=3; break;
}
speaker=~speaker;
SH0=tab[key]/256;
SL0=tab[key]%256;
TR0=1;
temp=P2;
temp=temp&0x0f;
while(temp!=0x0f)
{
temp=P2;
temp=temp&0x0f;
}
TR0=0;
}
}
P2=0XFF;
P25=0;
temp=P2;
temp=temp&0x0f;
if(temp!=0x0f)
{
sdelay(5);
temp=P2;
temp=temp&0x0f;
if(temp!=0x0f)
{
temp=P2;
temp=temp&0x0f;
switch(temp)
{
case 0x0e: key=4; break;
case 0x0d: key=5; break;
case 0x0b: key=6; break;
case 0x07: key=7; break;
}
speaker=~speaker;
SH0=tab[key]/256;
SL0=tab[key]%256;
TR0=1;
temp=P2;
temp=temp&0x0f;
while(temp!=0x0f)
{
temp=P2;
temp=temp&0x0f;
}
TR0=0;
}
}
P2=0XFF;
P26=0;
temp=P2;
temp=temp&0x0f;
if(temp!=0x0f)
{
sdelay(5);
temp=P2;
temp=temp&0x0f;
if(temp!=0x0f)
{
temp=P2;
temp=temp&0x0f;
switch(temp)
{
case 0x0e: key=8; break;
case 0x0d: key=9; break;
case 0x0b: key=10; break;
case 0x07: key=11;break;
}
speaker=~speaker;
SH0=tab[key]/256;
SL0=tab[key]%256;
TR0=1;
temp=P2;
temp=temp&0x0f;
while(temp!=0x0f)
{
temp=P2;
temp=temp&0x0f;
}
TR0=0;
}
}
P2=0XFF;
P27=0;
temp=P2;
temp=temp&0x0f;
if(temp!=0x0f)
{
sdelay(5);
temp=P2;
temp=temp&0x0f;
if(temp!=0x0f)
{
temp=P2;
temp=temp&0x0f;
switch(temp)
{
case 0x0e: key=12; break;
case 0x0d: key=13; break;
case 0x0b: key=14; break;
case 0x07: key=15; break;
}
speaker=~speaker;
SH0=tab[key]/256;
SL0=tab[key]%256;
TR0=1;
temp=P2;
temp=temp&0x0f;
while(temp!=0x0f)
{
temp=P2;
temp=temp&0x0f;
}
TR0=0;
}
}
return key ;
}
void timer0() interrupt 1
{
TH0=SH0;
TL0=SL0;
speaker=!speaker;
}
void timeinit()
{
P1=0X00;
TMOD=0x01;
ET0=1;
EA=1;
}
void sdelay(uchar t)
{
uchar h;
for(;t>0;t--)
for(h=255;h>0;h--)
;
//return 0;
}
热心网友
时间:2024-10-13 10:47
这是金聚宝的板子。
播放乐曲是可以的。
到我的百度空间看看,可以找到编写任意乐曲的方法。
http://hi.baidu.com/%D7%F6%B6%F8%C2%DB%B5%C0/blog/item/88bfff323ec42ef21b4cff09.html
热心网友
时间:2024-10-13 10:47
好难