- MicroPython Cookbook
- Marwan Alsabbagh
- 91字
- 2021-06-24 14:28:16
There's more...
Even though using start_tone and stop_tone requires more lines of code than simply calling play_tone, they allow you to do things that wouldn't be possible with just play_tone. For example, you can use your script to perform other tasks while audio is playing in the background.
In this recipe, the light and sound output were changed together. However, you could use the same technique to play a tone until someone presses a certain button. Alternatively, you could change the tones being played in reaction to different buttons being pressed.