IO口输出固定频率和占空比的PWM信号驱动蜂鸣器鸣响
void buz(void)
{
if(buz_flg)
{
buz_cnt = 200; //运行200ms 0.2s
Pwm0Init(1000,500); //频率1k,占空比%50
buz_flg = 0;
}
if(buz_cnt == 0)
{
Pwm0Init(1000,0); //占空比为0,不响
}
}
使用方法
buz_flg = 1;
标签:buz,cnt,蜂鸣器,void,占空比,驱动,pwm,flg
From: https://www.cnblogs.com/logicexpression/p/17555731.html