Skip to content

MicroPython Library for UART control of the Adafruit Soundboard

License

Notifications You must be signed in to change notification settings

mmabey/Adafruit_Soundboard_uPy

Repository files navigation

Adafruit Soundboard Library

Supported ports: pyboard, wipy, esp8266 Documentation Status CI Build Status License: MIT

The Adafruit Soundboards are an easy way to add sound to your maker project, but the library provided by Adafruit only supports Arduino.

If you've wanted to use one of these boards with a MicroPython or CircuitPython microcontroller (MCU), this is the library you've been looking for.

Installation

This driver depends on either MicroPython or CircuitPython and is intended for use to control one of the Adafruit Audio FX boards via UART.

Make sure to get the latest version of the code from GitHub.

CircuitPython Instructions

First, you'll need to get Adafruit CircuitPython. Then, please ensure all dependencies are available on the CircuitPython filesystem. This is easily achieved by downloading the Adafruit library and driver bundle.

MicroPython Instructions

At this time, you have to install the driver by copying the soundboard.py script to your MicroPython board along with your main.py file. At some point in the future it may be possible to pip install it.

Quick Start

First, you'll need to decide which UART bus you want to use. To do this, you'll need to consult the documentation for your particular MCU. In these examples, I'm using the original pyboard (see documentation here) and I'm using UART bus 1 or XB, which uses pin X9 for transmitting and ping X10 for receiving.

Then, create an instance of the :class:`~soundboard.Soundboard` class, like this:

sound = Soundboard('XB')

I highly recommend you also attach the RST pin on the sound board to one of the other GPIO pins on the MCU (pin X11 in the example). Also, my alternative method of getting the list of files from the board is more stable (in my own testing) than the method built-in to the sound board. Also, I like getting the debug output and I turn the volume down to 50% while I'm coding. Doing all this looks like the following:

SB_RST = 'X11'
sound = Soundboard('XB', rst_pin=SB_RST, vol=0.5, debug=True, alt_get_files=True)

Once you've set up all of this, you're ready to play some tracks:

# Play track 0
sound.play(0)

# Stop playback
sound.stop()

# Play the test file that comes with the sound board
sound.play('T00     OGG')

# Play track 1 immediately, stopping any currently playing tracks
sound.play_now(1)

# Pause and resume
sound.pause()
sound.unpause()

You can also control the volume in several different ways:

# Raise volume by 2 points (0 min volume, 204 max volume)
sound.vol_up()

# Turn down volume until lower than 125
sound.vol_down(125)

# Get the current volume
sound.vol

# Set volume to 56 (out of 204 maximum)
sound.vol = 56

# Set volume to 75% of maximum volume
sound.vol = 0.75

API Reference

.. toctree::
    :maxdepth: 2

    api


Contributing

Contributions are welcome! Please read our Code of Conduct before contributing to help this project stay welcoming.

License

This project is licensed under the MIT License.

About

MicroPython Library for UART control of the Adafruit Soundboard

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published