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