Fire engine sound
Onboard buzzer to simulate the sound effects of fire engines.
mBot/mCore Control Panel
Upload the program to Arduino
Online data suggests that, the fire engine siren’s low frequency sound is between 650Hz and 750Hz, and its high frequency sound is between 1450Hz and 1550Hz. The siren sound is generated by repeating the following pattern: the low frequency sound amplifies to a high frequency sound in 1.5 seconds, and then drops back to the lower frequency in 3.5 seconds. Therefore, the fire engine siren sounds can be programmatically simulated as follows:
set the low frequency to be 700Hz , and then set the high frequency sound to be 1500HZ, repeatedly playing the buzzer in a range from 700Hz to 1500Hz and then back to 700Hz. The ratio of amplification time to the drop time is 1.5:3.5, which is 3:7, so the ratio of frequency amplification to the drop needs to be 7:3. Then, by tuning the sound time and amplification v.s. drop’s amplitude, the fire engine siren is simulated.
|Define variable as the frequency of a tone and set the sounding duration as 12ms (12 here is for example only, and you can set it to any value you think proper).|
|Set the lower limit of variable as 700 and the upper limit of frequency as 1500.|
|This block indicates repeated run of the blocks within it until the conditon is established. When the condition is established, it will break the loop and run the following blocks.|
|This block means: set the initial value of tone frequency as 700Hz and sound it, and then increase the frequency by 35Hz each time and sound it until above 1500Hz, where it breaks the loop and the frequency will not be increased anymore.|
|This block means: set the initial value of tone frequency as 1500Hz and sound it, and then decrease the frequency by 15Hz each time and sound it until below 700Hz, where it breaks the loop and the frequency will not be decreased anymore.|
Why “repeat it until f>1500”, not “f=1500”?
That is because in the example of simulating the fire engine sound effects, it is hard to define the sounding duration each time when it is increased from 700Hz to 1500Hz and what increment it should be each time the frequency is increased. So we needd to debug the parameters. If we set f=1500, the final frequency should reach 1500 so that it can break the loop, or the frequency will be increased again and again, making it hard to debug. So we use f>1500, and when the frequency is above 1500, the loop will be broken and the following program decreasing the frequency will be executed.
Simulate police car sound effects: Low-frequency sound is set between 650Hz and 750Hz and high-frequency sound between 1450Hz to 1550Hz. It takes 0.23 seconds to raise a low-frequency sound to a high-frequency one and then 0.1 second to lower a high-frequency sound to a low-frequency one.
Attached – mCore main control board buzzer diagram
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.