2725 views|0 replies

1w

Posts

16

Resources
The OP
 

【ufun learning】Analysis of the buzzing routine [Copy link]

Buzzer is a good device used by microcontrollers to alert people.


I am more interested in this MLT-5020 because I have studied buzzing, and the bigger the buzzer, the louder it is.

As can be seen from the table above, the operating voltage is 3V, so I thought it would not be too loud. I tried the example program and it was indeed not too loud.

After looking at the routine, I thought that the timer was used to set various frequencies, but the routine is as follows:

int scale(int i)											//ò×±oˉêy
{
	int t;
	for(t=0;t<200000/i*2;t++)
	{
		GPIO_SetBits(GPIOA, GPIO_Pin_8);
		Delay_Us(i);
		GPIO_ResetBits(GPIOA, GPIO_Pin_8);
		Delay_Us(i);
	}
}

I didn't understand the 200,000, but after checking on Du Niang, I understood.

The frequency range of music is about 20Hz---20KHz, and the frequency range of human voice is about 300Hz---3.4KHz. But the highest frequency that humans can hear is 15KHz.

The routine gives the highest frequency first, and then gives different frequencies according to different scales. The *2 at the end is a cycle.


This content is originally created by EEWORLD forum user ddllxxrr . If you want to reprint or use it for commercial purposes, you must obtain the author's consent and indicate the source

Personal signaturehttp://shop34182318.taobao.com/
https://shop436095304.taobao.com/?spm=a230r.7195193.1997079397.37.69fe60dfT705yr
 
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list