Replies: 1 comment 1 reply
-
I don't know if this is the only issue, but from the SoftwareSerial docs: https://docs.arduino.cc/learn/built-in-libraries/software-serial/
|
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi everybody.
I have a question regarding the usage of SoftwareSerialMIDI_Interface.
I have a project using an Arduino Leonardo.
Due to a pin shortage and a poorly designed PCB, I ended up needing to use pin 1 as a GPIO for a 4051 multiplexer, while I need pin 0 to receive MIDI messages from a DIN midi connector.
So, I thought to use SoftwareSerialMIDI_Interface in order to do this, because hardware serial, as far as I understood, needs to occupy both 0 and 1 pins. Following is my code:
`#include <Control_Surface.h>
#include <SoftwareSerial.h>
#include "C:\Users\nicol\Documents\Arduino\libraries\Control_Surface\src\MIDI_Interfaces\SoftwareSerialMIDI_Interface.hpp"
SoftwareSerial mySer(0, -1); //I set the tx pin to -1 in order not to use any real pin
SoftwareSerialMIDI_Interface midi_ser = {mySer, MIDI_BAUD};
USBMIDI_Interface midi_usb;
MIDI_Pipe pipe_ctrl_USB, pipe_DIN_USB;
CD74HC4051 mux_pot1 { //U5
A0,
{13, 12, 11}
};
CD74HC4051 mux_pot2 { //U2
A1,
{6, 5, 4}
};
CD74HC4051 mux_SW1 { //U3
7,
{3, 2, 1}
};
CD74HC4051 mux_SW2 { //U4
A5,
{8, 9, 10}
};
CCPotentiometer potentiometers[]{
//FADERS
{mux_pot2.pin(4),{62, Channel_1}}, //RV1
{mux_pot2.pin(5),{63, Channel_1}}, //RV2
{mux_pot2.pin(6),{64, Channel_1}}, //RV3
{mux_pot2.pin(7),{65, Channel_1}}, //RV4
{mux_pot1.pin(3),{53, Channel_1}}, //RV5
{mux_pot1.pin(7),{57, Channel_1}}, //RV6
{mux_pot1.pin(5),{55, Channel_1}}, //RV7
{mux_pot1.pin(6),{56, Channel_1}}, //RV8
{mux_pot1.pin(4),{54, Channel_1}}, //RV9
//ROTARY POTS
{mux_pot2.pin(0),{58, Channel_1}}, //RV10
{mux_pot2.pin(1),{59, Channel_1}}, //RV11
{mux_pot2.pin(2),{60, Channel_1}}, //RV12
{mux_pot2.pin(3),{61, Channel_1}}, //RV13
{mux_pot1.pin(2),{52, Channel_1}}, //RV14
{mux_pot1.pin(1),{51, Channel_1}}, //RV15
{mux_pot1.pin(0),{50, Channel_1}}, //RV16
{A2, {66, Channel_1}}, //RV17
{A3, {1, Channel_1}}, //potH joystick
};
PBPotentiometer PitchBend2 { //potV joystick
A4, // Analog pin connected to potentiometer
Channel_1, // MIDI Channel 1
};
CCButton buttons[]{
{mux_SW1.pin(4), {73, Channel_1}}, //S4
{mux_SW1.pin(2), {72, Channel_1}}, //S3
{mux_SW1.pin(6), {71, Channel_1}}, //S2
{mux_SW1.pin(1), {70, Channel_1}}, //S1
{mux_SW2.pin(1), {74, Channel_1}}, //S5
{mux_SW2.pin(2), {75, Channel_1}}, //S6
{mux_SW2.pin(4), {76, Channel_1}}, //S7
{mux_SW2.pin(6), {77, Channel_1}}, //S8
};
CCButton pushbuttons[]{
{mux_SW1.pin(0), {80, Channel_1}}, //SW1
{mux_SW1.pin(3), {81, Channel_1}}, //SW2
{mux_SW1.pin(5), {82, Channel_1}}, //SW3
{mux_SW1.pin(7), {83, Channel_1}}, //SW4
{mux_SW2.pin(0), {84, Channel_1}}, //SW5
{mux_SW2.pin(3), {85, Channel_1}}, //SW6
{mux_SW2.pin(5), {86, Channel_1}}, //SW7
{mux_SW2.pin(7), {87, Channel_1}}, //SW8
};
void setup() {
midi_usb.setAsDefault();
Control_Surface >> pipe_ctrl_USB >> midi_usb; //Control surface sends messages to USB interface
midi_ser >> pipe_DIN_USB >> midi_usb; //MIDI coming from the DIN socket sends messages to USB interface
for (int i=9; i<17; i++){ // Faders are inverted for Hammond drawbars
potentiometers[i].invert();
}
Control_Surface.begin();
}
void loop() {
Control_Surface.loop();
}
`
The control surface part works as expected: all pots and switches send MIDI messages to the USB interface, but when I play something with my keyboard attached to the MIDI DIN plug, nothing is sent to the USB interface (and I also assume nothing is received by the Software serial (?)).
Could anyone tell me what I am doing wrong and if my problem can be solved?
Please tell me if you need any additional info.
Thank you so much in advance.
Beta Was this translation helpful? Give feedback.
All reactions