Hello,
I want to send MIDI on/off messages with the Trellis. According to those on the internet, it's super easy. I'm finding it hard. The code I'm using is the Trellis Test that comes in the Trellis library, with MIDI code copied from another basic Trellis library that doesn't work.
The Trellis Test code aspect of this sketch still functions as intended, but I get no MIDI reading when using the MIDI Monitor 2 software. Please help. Thanks.
I want to send MIDI on/off messages with the Trellis. According to those on the internet, it's super easy. I'm finding it hard. The code I'm using is the Trellis Test that comes in the Trellis library, with MIDI code copied from another basic Trellis library that doesn't work.
The Trellis Test code aspect of this sketch still functions as intended, but I get no MIDI reading when using the MIDI Monitor 2 software. Please help. Thanks.
Code:
#include <Wire.h>
#include "Adafruit_Trellis.h"
#include <MIDI.h>
#define MOMENTARY 0
#define MODE MOMENTARY
#define NUMTRELLIS 1
#define numKeys (NUMTRELLIS * 16)
#define INTPIN 13
Adafruit_Trellis matrix0 = Adafruit_Trellis();
Adafruit_TrellisSet trellis = Adafruit_TrellisSet(&matrix0);
int velocity = 100;
int noteON = 144;
int noteOFF = 128;
void setup() {
pinMode(INTPIN, INPUT);
digitalWrite(INTPIN, HIGH);
}
void loop() {
delay(30);
if (MODE == MOMENTARY) {
if (trellis.readSwitches()) {
for (int8_t i=0; i<numKeys; i++) {
if (trellis.justPressed(i)) {
MIDImessage(noteON, 48+1, velocity);
trellis.setLED(i);
}
if (trellis.justReleased(i)) {
MIDImessage(noteOFF, 48+i, velocity);
trellis.clrLED(i);
}
}
trellis.writeDisplay();
}
}
}
void MIDImessage(int command, int MIDInote, int MIDIvelocity) {
Serial.write(command);
Serial.write(MIDInote);
Serial.write(MIDIvelocity);
}