标题:
普中单片机蜂鸣器驱动程序
[打印本页]
作者:
暂无反应
时间:
2021-5-3 17:21
标题:
普中单片机蜂鸣器驱动程序
新学会了用蜂鸣器
普中的蜂鸣器是无源的,需要晶振才能响。
这里使用的是100微秒的周期
端口是P1^5
单片机源程序如下:
#include <reg51.h>
sbit buzzer=P1^5;
void Delay100us() //@11.0592MHz
{
unsigned char i;
i = 43;
while (--i);
}
void main()
{
while(1)
{
buzzer=1;
Delay100us();
buzzer=0;
Delay100us();
}
}
复制代码
欢迎光临 (http://www.51hei.com/bbs/)
Powered by Discuz! X3.1