51单片机蜂鸣器唱歌程序
运行后一是只唱了大概五六个音二是之后就一直bi~~~~~~~也不执行关闭,是为什么啊有没有大神能教一下#include<reg51.h>unsignedintm,i;//...
运行后
一是只唱了大概五六个音
二是之后就一直bi~~~~~~~也不执行关闭,是为什么啊
有没有大神能教一下
#include <reg51.h>
unsigned int m,i;//i控制音调和节拍;
code unsigned int time[]={1275,1136,956,852,758,1275,1136,1275,1136,956,758,668,568,758,956,852,956,852,758,
668,758,852,852,852,852,758,852,956,956,1136,1275,1275,956,852,758,852,758,852,758,668,852,852,758,668,568,
758,956,852,956,852,758,668};//音调
code unsigned int pai[]={80,80,80,80,320,160,80,40,40,640,1600,80,80,240,80,120,40,80,40,40,320,80,80,40,40,40,
40,40,80,40,40,80,240,80,120,40,40,40,40,40,320,320,160,80,80,240,80,120,40,80,40,40,0};//节拍
sbit beep=P1^5;
void t1_init() interrupt 3
{
TH1=(65535-10000)/256;
TL1=(65535-10000)%256;
m++;
if(m==pai[i])
{
i++;
m=0;
}
else if(pai[i]==0)
{beep=1;TR0=0;TR1=0;}
}
void t0_init() interrupt 1
{
TH0=(65535-time[i])/256;
TL0=(65535-time[i])%256;
beep=~beep;
}
void sys_init()
{
TMOD=0X11;
TH0=(65535-time[i])/256;
TL0=(65535-time[i])%256;
ET0=1;
EA=1;
TR0=1;
beep=0;
m=0;
////////
TH1=(65535-10000)/256;
TL1=(65535-10000)%256;
ET1=1;
TR1=1;
i=0;
}
void main()
{
sys_init();
while(1);
} 展开
一是只唱了大概五六个音
二是之后就一直bi~~~~~~~也不执行关闭,是为什么啊
有没有大神能教一下
#include <reg51.h>
unsigned int m,i;//i控制音调和节拍;
code unsigned int time[]={1275,1136,956,852,758,1275,1136,1275,1136,956,758,668,568,758,956,852,956,852,758,
668,758,852,852,852,852,758,852,956,956,1136,1275,1275,956,852,758,852,758,852,758,668,852,852,758,668,568,
758,956,852,956,852,758,668};//音调
code unsigned int pai[]={80,80,80,80,320,160,80,40,40,640,1600,80,80,240,80,120,40,80,40,40,320,80,80,40,40,40,
40,40,80,40,40,80,240,80,120,40,40,40,40,40,320,320,160,80,80,240,80,120,40,80,40,40,0};//节拍
sbit beep=P1^5;
void t1_init() interrupt 3
{
TH1=(65535-10000)/256;
TL1=(65535-10000)%256;
m++;
if(m==pai[i])
{
i++;
m=0;
}
else if(pai[i]==0)
{beep=1;TR0=0;TR1=0;}
}
void t0_init() interrupt 1
{
TH0=(65535-time[i])/256;
TL0=(65535-time[i])%256;
beep=~beep;
}
void sys_init()
{
TMOD=0X11;
TH0=(65535-time[i])/256;
TL0=(65535-time[i])%256;
ET0=1;
EA=1;
TR0=1;
beep=0;
m=0;
////////
TH1=(65535-10000)/256;
TL1=(65535-10000)%256;
ET1=1;
TR1=1;
i=0;
}
void main()
{
sys_init();
while(1);
} 展开
3个回答
展开全部
[2]单片机音乐盒花样流水灯设计
功能描述:
1、按键切换音乐
2、彩灯可以跟随音调亮灭
3、按键切换彩灯显示花样
4、支持功能定制
☆已作出的实物优酷视频演示地址:
http://v.youku.com/v_show/id_XMTUxMDU3MzcyOA==.html
功能描述:
1、按键切换音乐
2、彩灯可以跟随音调亮灭
3、按键切换彩灯显示花样
4、支持功能定制
☆已作出的实物优酷视频演示地址:
http://v.youku.com/v_show/id_XMTUxMDU3MzcyOA==.html
宿兴电子
2024-11-28 广告
2024-11-28 广告
联系我们蜂鸣器的种类规格繁多,需先知道几个参数 ( 电压,电流,驱动方式,尺寸,连接/固定方式),当然更重要的是,想要获的声音 (音压大小,频率高低).工作电压:电磁式蜂鸣器,从1.5到24V, 压电式的从3V到220V都是可行的,但一般压...
点击进入详情页
本回答由宿兴电子提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询