Your code worked with the Teensy 4 but not on the Trinket. The Trinket outputs "Not found, error 2"
I'm about to give up on the trinket, though I have another one coming in the mail, maybe this one's problematic.
FYI, this is the full sketch that does everything I wanted at this point, assuming I use Teensy, which is just a simple midi slider for RME Totalmix. I'll probably add something like double tap to toggle mute.
I just wanted it to work on the Trinket because it's smaller and cheaper for this simplistic project. And I have a more complex idea that will go on the Teensy
Any suggestion for a cheap, small board that powers off usb and would run this very simple midi controller that plays well with Bela?
#include <Wire.h>
#include <Trill.h>
Trill trill;
int lastVal = -1;
void setup() {
usbMIDI.begin();
int result = trill.setup(Trill::TRILL_FLEX, 0x48);
if (result == 0) {
trill.setMode(Trill::CENTROID);
delay(100);
trill.setPrescaler(4);
delay(200);
trill.updateBaseline();
delay(200);
delay(2000);
trill.updateBaseline();
}
}
void loop() {
trill.read();
if (trill.getNumTouches() > 0) {
int location = trill.touchLocation(0);
int val = map(location, 0, 3712, 0, 127);
val = constrain(val, 0, 127);
if (abs(val - lastVal) > 1) {
usbMIDI.sendControlChange(7, val, 1);
lastVal = val;
}
}
delay(20);
while (usbMIDI.read()) {}
}