User Manual
You must drag/copy this onto your CIRCUITPY disk drive, it's a big file so it will take a minute to copy over
Import Libraries
We start by importing the libraries that we need to make audio output import audioio Then we import board , our
standardhardware library.
Create wave file and audio output
Next we set the name of the file we want to open, which is a wave file wavfile = "howto.wav" and then open the file
as a readable binary and store the file object in f which is what we use to actually read audio from: f = open(wavfile,
"rb")
Now we will ask the audio playback system to load the wave data from the file wav = audioio.WaveFile(f) and finally
request that the audio is played through the A0 analog output pin a = audioio.AudioOut(board.A0)
The audio file is now locked-and-loaded, and can be played at any time with a.play(wav)
Audio playback occurs in the background, using "DMA" (direct memory access) so you can control servos, motors, read
sensors, whatever you like, while the DMA is happening. Since it happens asynchronously, you may want to figure out
when its done playing. You can do that by checking the value of a.playing if it's True then its still processing audio, it
will return False when complete.
Interactive Audio
OK just playing an audio file is one thing, but maybe you want to have some interactivity, such as waiting for the person
to touch something or press a button? Here's an example of using a time-delay and then pausing until something
occurs:
© Adafruit Industries
https://learn.adafruit.com/adafruit-crickit-creative-robotic-interactive-
construction-kit
Page 116 of 201










