Using the Adafruit STEMMA speaker is as simple as connecting it to your project. Existing audio code works the same way but will use the STEMMA speaker instead. Let's take a look at an example using Circuit Playground Express.

You can use any device that outputs analog 'line level' audio signal, we're testing with a Circuit Playground but you can use for any general purpose audio output amplification!

Circuit Playground Express Wiring

First, wire up the STEMMA speaker to a Circuit Playground Express as shown. We suggest using a 3-pin JST to alligator clip cable with the 3-pin JST connector on the STEMMA Speaker.

  • Plug the 3-pin JST to alligator clip cable into the 3-pin JST connector on the STEMMA Speaker
  • Connect the black alligator clip to a GND pad on the CPX
  • Connect the white alligator clip to the A0 pad
  • Connect the red alligator clip to the VOUT pad

Circuit Playground Express Example Code

This example uses CircuitPython. If you're not already using CircuitPython, check out this quick-start to get it going.

The first example plays a different tone for each button on the Circuit Playground Express.

Copy the following code to a code.py file on your CIRCUITPY drive:

from adafruit_circuitplayground.express import cpx

while True:
    if cpx.button_a:
        cpx.play_tone(260, 1)
    if cpx.button_b:
        cpx.play_tone(292, 1)

Press each button to play a different tone through your STEMMA speaker.

The second example plays a different wav file for each button on the Circuit Playground Express.

Click the buttons below to download the two wav files and copy them to your CIRCUITPY drive.

Then, copy the following code to a code.py file on your CIRCUITPY drive:

from adafruit_circuitplayground.express import cpx

while True:
    if cpx.button_a:
        cpx.play_file("rise.wav")
    if cpx.button_b:
        cpx.play_file("dip.wav")

Press each button on the Circuit Playground Express to play each file through your STEMMA Speaker.

That's all there is to using your STEMMA Speaker with Circuit Playground Express and CircuitPython!

Further Information

For more information on using the STEMMA Speaker with MakeCode, check out the Music and Sound in MakeCode page of the Make It Sound guide.

For more information on using the STEMMA Speaker with CircuitPython, check out the Music and Sound in CircuitPython page of the Make It Sound guide.

This guide was first published on Oct 04, 2019. It was last updated on Oct 04, 2019.

This page (Usage) was last updated on Oct 22, 2021.

Text editor powered by tinymce.