
上QQ阅读APP看书,第一时间看更新
How it works...
The first line of code imports the Circuit Playground Express library. The cpx object exposes a method called play_tone. This method accepts two arguments: frequency and duration. These arguments specify the frequency of the sound in Hz, and how long the sound will be played in seconds.
The duration can be given as a floating point number. This means that a value such as 0.2 will correlate to 200 milliseconds. This method call is a blocking call. So, calling the method will start playing the audio and it won't return anything until the specified time has elapsed.