BlueKaiTheEnd
Member
I want to use a Teensy 4.0 board to send MIDI messages through USB. I'm trying to connect it with LMMS. I have a simple sketch where bytes of data is sent on the press of a button. The code compiles and the sketch uploads to the board without error. LMMS is able to see the board as "Teensy MIDI" when selecting the board as input for a preset. But no sound is generated from the program when I press a button.
The header pins are already soldered to the board. I'm running the code in the Arduino IDE, with "USB Type" set to "MIDI" in the tools menu and using the correct port.
I feel like I'm overlooking something. Here is my code:
I've also referenced these guides and videos numerous times:
https://www.pjrc.com/teensy/td_midi.html
https://www.youtube.com/watch?v=E_GdsxTm6aM
The header pins are already soldered to the board. I'm running the code in the Arduino IDE, with "USB Type" set to "MIDI" in the tools menu and using the correct port.
I feel like I'm overlooking something. Here is my code:
Code:
#include <Arduino.h>
#include <Metro.h>
#include <Bounce.h>
#include <Encoder.h>
#define btn0 22
#define led0 14
const long DEBOUNCE_DELAY = 5;
const byte MIDI_LISTEN_CH = 4;
const byte VELOCITY = 127;
const byte MIDI_CH = 1;
byte note[] = {36,37,38,39,40,41};
Metro buttonPress = Metro(3);
Bounce btn_0 = Bounce(btn0, DEBOUNCE_DELAY);
void setup() {
pinMode(btn0, INPUT_PULLUP);
pinMode(led0, OUTPUT);
Serial.begin(115200);
usbMIDI.begin();
}
void loop() {
if(buttonPress.check()){
btn_0.update();
if(btn_0.fallingEdge()) {
Serial.println("Button 0 Released");
digitalWrite(led0, HIGH);
usbMIDI.sendNoteOn(note[0], VELOCITY, MIDI_CH);
}
if(btn_0.risingEdge()) {
Serial.println("Button 0 Pressed");
digitalWrite(led0, LOW);
usbMIDI.sendNoteOff(note[0], VELOCITY, MIDI_CH);
}
}
while (usbMIDI.read()) {} //read and ingnore incoming messages
}
I've also referenced these guides and videos numerous times:
https://www.pjrc.com/teensy/td_midi.html
https://www.youtube.com/watch?v=E_GdsxTm6aM