Installing Arduino

You'll need to customize some settings in the Arduino IDE to get configured to compile code onto the Adafruit Pro Trinket.  Be sure to check out the Introduction to Pro Trinket guide for setting that up.

Library Dependencies 

The following libraries are needed to compile the arduino sketch.

Uploading Sketch

With the Adafruit Arduino IDE and libraries installed, create a new sketch. Paste the desired code into the text editor. Select Pro Trinket from Tools > Board. Then USBtinyISP from Tool > Programmmer. Proceede by pluging a micro USB cable from your computer to the Pro Trinket. Watch for the red LED to start blinking and click upload to compile the sketch onto the Pro Trinket. If everything is good, Arduino will prompt with you a successful message in the console window.

Customizing Tracks

You'll most likely want to change out the audio samples in this project. Look for the line where it lists out char PadToTrack[numKeys][12]. The track file names are listed here. These should have the same names of the audio files on the Audio FX soundboard. See this guide for file naming conventions.

The code is in this GitHub repo. If you find there are issues, you can use the GitHub Pull Request to suggest a fix.

// SPDX-FileCopyrightText: 2019 Anne Barela for Adafruit Industries
// SPDX-License-Identifier: MIT

#include <Wire.h>
#include "Adafruit_Trellis.h"
#include <SoftwareSerial.h>
#include "Adafruit_Soundboard.h"
/************ sound board setup ***********/
// Choose any two pins that can be used with SoftwareSerial to RX & TX
#define SFX_TX 5
#define SFX_RX 6
// Connect to the RST pin on the Sound Board
#define SFX_RST 4
#define SFX_ACT 1 // the 'ACT'ivity LED, to tell us if we're still playing
// You can also monitor the ACT pin for when audio is playing!
// we'll be using software serial
SoftwareSerial ss = SoftwareSerial(SFX_TX, SFX_RX);
// pass the software serial to Adafruit_soundboard, the second
// argument is the debug port (not used really) and the third 
// arg is the reset pin
Adafruit_Soundboard sfx = Adafruit_Soundboard(&ss, NULL, SFX_RST);
/************ Trellis setup ***********/
Adafruit_Trellis matrix0 = Adafruit_Trellis();
Adafruit_TrellisSet trellis =  Adafruit_TrellisSet(&matrix0);
// set to however many you're working with here, up to 8
#define NUMTRELLIS 1
#define numKeys (NUMTRELLIS * 16)
// Connect Trellis Vin to 5V and Ground to ground.
// Connect the INT wire to pin #A2 (can change later!)
#define INTPIN A2
// Connect I2C SDA pin to your Arduino SDA line
// Connect I2C SCL pin to your Arduino SCL line
char PadToTrack[numKeys][12] = {"T00RAND0WAV",
/************ main setup ***********/
void setup() {
  Serial.println("Trellis Demo");
  // INT pin requires a pullup
  pinMode(INTPIN, INPUT);
  digitalWrite(INTPIN, HIGH);
  // ACT LED
  pinMode(SFX_ACT, INPUT);
  digitalWrite(SFX_ACT, HIGH); //pullup
  // begin() with the addresses of each panel in order
  trellis.begin(0x70);  // only one

  // light up all the LEDs in order
  for (uint8_t i=0; i<numKeys; i++) {
  // then turn them off
  for (uint8_t i=0; i<numKeys; i++) {
  // softwareserial at 9600 baud
  if (!sfx.reset()) {
    Serial.println("SFX not found");
    while (1);
  Serial.println("SFX board found");
  uint8_t files = sfx.listFiles();
  Serial.println("File Listing");
  Serial.print("Found "); Serial.print(files); Serial.println(" Files");
  for (uint8_t f=0; f<files; f++) {
    Serial.print("\tname: "); Serial.print(sfx.fileName(f));
    Serial.print("\tsize: "); Serial.println(sfx.fileSize(f));
int currentPlaying = -1;
void loop() {
  delay(30); // 30ms delay is required, dont remove me!
  if (digitalRead(SFX_ACT) && (currentPlaying != -1)) {
     // *not* playing anything according to ACT lite
     currentPlaying = -1;
  // If a button was just pressed or released...
  if (trellis.readSwitches()) {
    // go through every button
    for (uint8_t i=0; i<numKeys; i++) {
       // if it was pressed, turn it on
       if (trellis.isKeyPressed(i) && (i != currentPlaying)) {
          Serial.print("v"); Serial.println(i);
//          if (! digitalRead(SFX_ACT)) {
//            Serial.println("stop..."); // check ACT lite first?
//            if (! sfx.stop() ) {
//                Serial.println("Failed to stop");
//            }
//          }
          // play!         
          char * filename = PadToTrack[i];
          int ret = sfx.playTrack(filename);
          Serial.print("Playing "); Serial.println(filename);
          if (! ret) {
            Serial.println("Failed to play track?");
          } else {
          delay(25);  // give it a chance to start playing
          currentPlaying = i;

This guide was first published on Apr 13, 2015. It was last updated on Mar 30, 2015.

This page (Software) was last updated on Mar 30, 2015.

Text editor powered by tinymce.