3个回答
2013-07-10
展开全部
#include <reg51.h>#include <intrins.h> sbit SPK = P3^4; unsigned char frq; void delayms(unsigned char ms) // 延时子程序{ unsigned char i; while(ms--) { for(i = 0; i < 120; i++); }} void timer0() interrupt 1 using 1{ TH0 = 0xfe; TL0 = frq; SPK = ~SPK; } main(){ TMOD = 0x01; frq = 0x00; TH0 = 0x00; TL0 = 0xff; TR0 = 1; IE = 0x82; while(1) { frq++; delayms(1); //改变此处可以改变报警声的节奏长度 }}
宿兴电子
2024-11-28 广告
2024-11-28 广告
产品展示1.压电式蜂鸣器 压电式蜂鸣器主要由多谐振荡器、压电蜂鸣片、阻抗匹配器及共鸣箱、外壳等组成。有的压电式蜂鸣器外壳上还装有发光二极管。多谐振荡器由晶体管或集成电路构成。当接通电源后(1.5~15V直流工作电压),多谐振荡器起振,输出1...
点击进入详情页
本回答由宿兴电子提供
展开全部
#include <reg52.h>
sbit SPK = P1^0;
unsigned char frq;
void delayms(unsigned char ms) // 延时子程序
{
unsigned char i;
while(ms--) for(i = 0; i < 120; i++);
}
void timer0() interrupt 1
{
TH0 = 0xfe;
TL0 = frq;
SPK = ~SPK;
}
main()
{
TMOD = 0x01;
frq = 0x00;
TH0 = 0xfe;
TL0 = 0;
TR0 = 1;
IE = 0x82;
while(1)
{ frq++;
delayms(1);
}
}
sbit SPK = P1^0;
unsigned char frq;
void delayms(unsigned char ms) // 延时子程序
{
unsigned char i;
while(ms--) for(i = 0; i < 120; i++);
}
void timer0() interrupt 1
{
TH0 = 0xfe;
TL0 = frq;
SPK = ~SPK;
}
main()
{
TMOD = 0x01;
frq = 0x00;
TH0 = 0xfe;
TL0 = 0;
TR0 = 1;
IE = 0x82;
while(1)
{ frq++;
delayms(1);
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-07-10
展开全部
flag bit 00h
org 0h
ljmp start
org 30
start: jb p3.7,start
jnb flag,next mov r2,#200
sp0: cpl p3.0
lcall delay
lcall delay
djnz r2,sp0
cpl flagnext: mov r2,#200
sp1: cpl p3.0
lcall delay
djnz r2,sp1
cpl flag
sjmp start
delay: mov r7,#250
loop: nop
djnz r7,loop
ret
end
org 0h
ljmp start
org 30
start: jb p3.7,start
jnb flag,next mov r2,#200
sp0: cpl p3.0
lcall delay
lcall delay
djnz r2,sp0
cpl flagnext: mov r2,#200
sp1: cpl p3.0
lcall delay
djnz r2,sp1
cpl flag
sjmp start
delay: mov r7,#250
loop: nop
djnz r7,loop
ret
end
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询