展开全部
用语言芯片不好。ISD4003可以录音8分钟的,方原声都得
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
#include <reg52.h>
#define uint unsigned int
#define uchar unsigned char
sbit BEEP=P1^2;
uint h,i;
uint hz;
uchar jiep;
bit flag;
uint code fre[]={ 64400,64524,64580,64684,64777,64820,64898,64968,65030,65058,65110,65157,65178,65217};
uchar code song[]={6,9, 6,3, 7,12, 6,12, 9,12, 8,24, 6,9, 6,3, 7,12,
6,12, 10,12, 9,24, 6,9, 6,3, 13,12, 11,12, 8,12, 7,12,
12,9, 12,3, 11,12, 9,12, 10,12, 9,24}; //歌谱 2个一组(0,0)(音调,节拍)
void init () //初始化
{
EA=1;
TMOD=0x11;
ET0=1;
ET1=1;
i=0;
flag=1;
}
void sing()
{
if(flag==1)
{
h=song[i];
jiep=song[i+1];
i=i+2;
if(i>46) i=0;
hz=fre[h];
TH0=(hz)/256;
TL0=(hz)%256;
flag=0;
TR0=1;
TR1=1;
}
}
void main()
{
init();
while(1)
{
sing();
}
}
void time0() interrupt 1 //定时器0
{
TH0=(hz)/256;
TL0=(hz)%256;
if(!flag) BEEP=!BEEP;
else TR0=0;
}
void time1() interrupt 3
{
TH1=(15536)/256;
TL1=(15536)%256;
--jiep;
if(jiep==0)
flag=1;
}
#define uint unsigned int
#define uchar unsigned char
sbit BEEP=P1^2;
uint h,i;
uint hz;
uchar jiep;
bit flag;
uint code fre[]={ 64400,64524,64580,64684,64777,64820,64898,64968,65030,65058,65110,65157,65178,65217};
uchar code song[]={6,9, 6,3, 7,12, 6,12, 9,12, 8,24, 6,9, 6,3, 7,12,
6,12, 10,12, 9,24, 6,9, 6,3, 13,12, 11,12, 8,12, 7,12,
12,9, 12,3, 11,12, 9,12, 10,12, 9,24}; //歌谱 2个一组(0,0)(音调,节拍)
void init () //初始化
{
EA=1;
TMOD=0x11;
ET0=1;
ET1=1;
i=0;
flag=1;
}
void sing()
{
if(flag==1)
{
h=song[i];
jiep=song[i+1];
i=i+2;
if(i>46) i=0;
hz=fre[h];
TH0=(hz)/256;
TL0=(hz)%256;
flag=0;
TR0=1;
TR1=1;
}
}
void main()
{
init();
while(1)
{
sing();
}
}
void time0() interrupt 1 //定时器0
{
TH0=(hz)/256;
TL0=(hz)%256;
if(!flag) BEEP=!BEEP;
else TR0=0;
}
void time1() interrupt 3
{
TH1=(15536)/256;
TL1=(15536)%256;
--jiep;
if(jiep==0)
flag=1;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
#include<reg51.h>
#define uchar unsigned char
#define uint unsigned int
sbit BEEP=P2^6;
void Music(uchar number);
void delay10us(uchar time);
void delay50us(uchar time);
uchar code SOUNDLONG[]= //控制音调
{
18,6,24,24,24,48,
18,6,24,24,24,48,
18,6,24,24,24,24,24,
18,6,24,24,24,48,0
};
uchar code SOUNDTONE[]= //控制音色
{
212,212,190,212,159,169,
212,212,190,212,142,159,
212,212,106,126,159,169,190,
119,119,126,159,142,159,0 //生日快乐end
};
void Play_Music()
{
uint k,n;
uint SoundLong,SoundTone;
uint i,j,m;
do
{
if(i>=25) i=0;
SoundLong=SOUNDLONG[i];
SoundTone=SOUNDTONE[i];
i++;
for(n=0;n<SoundLong;n++)
{
for(k=0;k<12;k++)
{
BEEP=0;
for(m=0;m<SoundTone;m++);
BEEP=1;
for(m=0;m<SoundTone;m++);
}
}
delay50us(6);
}while((SOUNDLONG[i]!=0)||(SOUNDTONE[j]!=0));
}
//延时程序
void delay10us(uchar time)
{
uchar a,b,c;
for(a=0;a<time;a++)
for(b=0;b<10;b++)
for(c=0;c<120;c++);
}
void delay50us(uchar time)
{
uchar a,b;
for(a=0;a<time;a++)
for(b=0;b<6;b++);
}
void main()
{
while(1)
{
Play_Music(); //生日快乐
delay10us(250);
}
}
#define uchar unsigned char
#define uint unsigned int
sbit BEEP=P2^6;
void Music(uchar number);
void delay10us(uchar time);
void delay50us(uchar time);
uchar code SOUNDLONG[]= //控制音调
{
18,6,24,24,24,48,
18,6,24,24,24,48,
18,6,24,24,24,24,24,
18,6,24,24,24,48,0
};
uchar code SOUNDTONE[]= //控制音色
{
212,212,190,212,159,169,
212,212,190,212,142,159,
212,212,106,126,159,169,190,
119,119,126,159,142,159,0 //生日快乐end
};
void Play_Music()
{
uint k,n;
uint SoundLong,SoundTone;
uint i,j,m;
do
{
if(i>=25) i=0;
SoundLong=SOUNDLONG[i];
SoundTone=SOUNDTONE[i];
i++;
for(n=0;n<SoundLong;n++)
{
for(k=0;k<12;k++)
{
BEEP=0;
for(m=0;m<SoundTone;m++);
BEEP=1;
for(m=0;m<SoundTone;m++);
}
}
delay50us(6);
}while((SOUNDLONG[i]!=0)||(SOUNDTONE[j]!=0));
}
//延时程序
void delay10us(uchar time)
{
uchar a,b,c;
for(a=0;a<time;a++)
for(b=0;b<10;b++)
for(c=0;c<120;c++);
}
void delay50us(uchar time)
{
uchar a,b;
for(a=0;a<time;a++)
for(b=0;b<6;b++);
}
void main()
{
while(1)
{
Play_Music(); //生日快乐
delay10us(250);
}
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
89C51的芯片现在还能买得到么?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询