I am trying to make a small footswitch that will allow me to send midi program change commands to the sound board I am using. I am using an arduino leonardo with the sparkfun midi shield and plugging that into a midi monitor device so that i could see what i was outputing to make sure it was correct before plugging it into my sound board. My problem is that I have been unable to get any midi signal to be sent out of the midi port of the shield. I have tested the momentary switch to make sure I had that wired correctly with the led test code and got it to work so next I assumed it was my programming so I tried using test codes as well as different codes from people online who have done the same thing and I cannot seem to get anything to work. I am new to this so maybe I have missed something simple along the way, any help would be greatly appreciated.
I have not used the MIDI Shield, but I have worked with home-grown MIDI interfaces. Here are the most common glitches:
1a. The pinout on the DIN connectors is not obvious; double check the polarity (+ and -) using a voltmeter and a known-good device.
1b. Pins 4 and 5 are the two pins on either side of the center pint (ie NOT adjacent)
-
Make sure the MIDI Out of the shield is connected to MIDI In on your sound board; some devices are poorly labeled
-
You will have to set the UART baud rate to 31.5 kbps; it’s an unusual baud rate
If you think the wiring is good and the baud rate is good, try putting a MIDI cable from OUT to IN, and send one byte (or one short message); you should get the same message back.
Jake
If you can't solve your problem via the aforementioned, post a schematic or wiring diagram and your code. Right now "we" have nothing to go on.theatreguy:
I am new to this so maybe I have missed something simple along the way, any help would be greatly appreciated.
(click to open)
I don’t have a schematic but here is how the shield is hooked up. I have the 5v and ground connected to the shield in the labeled places as well as the tx and rx pins. As far as my code here it is so far.
#include <MIDI.h>
int button1 = 3; // choose the input pin (for a pushbutton)
int button2 = 4;
int val = 0; // variable for reading the pin status
int val2 = 0;
void setup() {
Serial.begin(31250);
pinMode(button1, INPUT);
pinMode(button2, INPUT); // declare pushbutton as input
}
void loop() {
val = digitalRead(button1); // read input value
if (val == HIGH) { // check if the input is HIGH (button released)
MIDI.sendProgramChange (1, 12);
delay(500);
val = LOW;
} else {
val2 = digitalRead(button2); {
if (val2 == HIGH) { // check if the input is HIGH (button released)
MIDI.sendProgramChange (2, 12);
delay(500);
val2 = LOW;
}
}
}
}
Right away I see one showstopper.
http://arduino.cc/en/Main/ArduinoBoardL … xXpa4WmWVI
In addition, some pins have specialized functions:
Serial: 0 (RX) and 1 (TX). Used to receive (RX) and transmit (TX) TTL serial data using the ATmega32U4 hardware serial capability. Note that on the Leonardo, the Serial class refers to USB (CDC) communication; for TTL serial on pins 0 and 1, use the Serial1 class.
At a minimum this;
Serial.begin(31250);
needs to be.
Serial1.begin(31250);
I’m unsure about the MIDI library. Give the above a try first.
I tried using serial1 as well as using softwareserial both without success. Here is my code for the software serial in case maybe I just screwed up the programming to get it to correctly work. I am going to try talking to sparkfun technical support since it is their shield just to make sure that it is something I am doing wrong however anymore revalations on where I screwed up would be greatly appreciated. Thank you for all your help so far.
#include <SoftwareSerial.h>
#include <MIDI.h>
SoftwareSerial mySerial(10, 11);
int button1 = 3; // choose the input pin (for a pushbutton)
int button2 = 4;
int val = 0; // variable for reading the pin status
int val2 = 0;
void setup() {
Serial.begin(9600);
while (!Serial); {
;
}
mySerial.begin(31250);
pinMode(button1, INPUT);
pinMode(button2, INPUT); // declare pushbutton as input
}
void loop()
{
if (mySerial.available())
Serial.write(mySerial.read());
if (Serial.available())
mySerial.write(Serial.read());
{
val = digitalRead(button1); // read input value
if (val == HIGH) { // check if the input is HIGH (button released)
MIDI.sendProgramChange (1, 12);
delay(500);
val = LOW;
} else {
val2 = digitalRead(button2); {
if (val2 == HIGH) { // check if the input is HIGH (button released)
MIDI.sendProgramChange (2, 12);
delay(500);
val2 = LOW;
}
}
}
}
}
Are buttons 1 & 2 are normally open and when pushed provide a short to ground ? Do you have a pull-up resistor tied to the input pins ? If not you should use the INPUT_PULLUP argument.
http://arduino.cc/en/Reference/PinMode#.Uxdzl4WmWVI
http://arduino.cc/en/Reference/Constants#.Uxdzr4WmWVI
http://arduino.cc/en/Tutorial/InputPull … xdz14WmWVI
I also note you don’t have a MIDI.begin(blah, blah) statement.