Serial output not working on Uno R3; Seeking debugging advice

Hi, I've just purchased an Uno R3. I am trying to send MIDI to a MIDI synth keyboard. I'm using the sample MIDI code found at http://arduino.cc/en/Tutorial/Midi

My Uno is connected to my MacBook and I'm able to (for example) run the sample Pin 13 LED flash code without a problem. So, my environment looks to be correct.

I have wired up a MIDI plug according to the schematic and triple checked it's connections, including the 220 ohm resistor.

When I run the sketch, I just can't seem to have my synth detect any MIDI coming from the Arduino Uno. Silence.

There are a couple of symptoms that may or may not be related: 1) MIDI requires a baud of 31250; since the serial monitor doesn't allow me to check that rate, I can't seem to debug this. 2) When I output text using Serial.println, I still see unrecognized characters being sent to the serial monitor... even in a different sketch that matches the baud (for example 9600) in both the Sketch and the monitor and does nothing but the Serial.println. 3) When I'm using USB power, I see a flicker on the TX LED when I run the MIDI sketch which sends a constant stream of commands... but when I disconnect USB power and use a 9V battery, I get no such flicker. The MIDI sketch produces no sound regardless of the power source.

Does anyone have any advice on what my next steps should be? In a couple of days I have another Uno arriving in the mail that I could test in case I have a hardware issue, but it's SO difficult to wait!

Any advice would be greatly appreciated. -Pete

VTPetr:

  1. MIDI requires a baud of 31250; since the serial monitor doesn’t allow me to check that rate, I can’t seem to debug this.

You could try a more capable serial terminal program. putty for windows. screen for osx/linux.

VTPetr:
2) When I output text using Serial.println, I still see unrecognized characters being sent to the serial monitor… even in a different sketch that matches the baud (for example 9600) in both the Sketch and the monitor and does nothing but the Serial.println.

Post the sketch you are using and the output you are getting. Since the board is programmed over USB/Serial, it would stand to reason serial communication is working correctly.

VTPetr:
use a 9V battery

If you’re talking about the small rectangular 9V batteries, don’t bother troubleshooting it. Those batteries are horrid and simply do not have enough energy for most Arduino projects. (They’re only designed to provide 25mA continuously and the Arduino board alone draws more than that on its own.)

Hi,

Ok, a couple of things happened to help me diagnose things, but still no joy.
I downloaded and installed “CoolTerm” that confirmed the serial data is formatted properly at the 31250 baud rate required by MIDI. I’m getting good note-on, pitch and velocities such as: 90 55 45 90 55 00. (Note on-channel 1, pitch 55, velocity 45, etc.) (In hex.)

I also received a second UNO which is doing the exact same thing, so that’s good.

I’ll post the sketch below.

I also ditched the 9V battery and found a 9V 1.5amp transformer to use.

When I run the program with my USB cable connected, I get nice blinking TX led lit (but no sound.) If I switch to just 9V power, there’s no more blinking. The TX light doesn’t come on at all IE, disconnecting the USB cable stops the blinking (resetting with just 9V power doesn’t help, either.)

I double checked my physical connections again. I’m set up exactly like the tutorial recommends.

Here’s the sketch:

void setup() {
// Set MIDI baud rate:
Serial.begin(31250);
}

void loop() {
// play notes from F#-0 (0x1E) to F#-5 (0x5A):
for (int note = 0x1E; note < 0x5A; note ++) {
//Note on channel 1 (0x90), some note value (note), middle velocity (0x45):
noteOn(0x90, note, 0x45);
delay(1000);
//Note on channel 1 (0x90), some note value (note), silent velocity (0x00):
noteOn(0x90, note, 0x00);
delay(100);
}
}

// plays a MIDI note. Doesn’t check to see that
// cmd is greater than 127, or that data values are less than 127:
void noteOn(int cmd, int pitch, int velocity) {
Serial.write(cmd);
Serial.write(pitch);
Serial.write(velocity);
}

-Pete

Yay! The best news... it was completely my fault! I did something so dumb that I'm afraid to mention it. When wiring up my midi port, I was looking at the front and wired the back that way; so the signal and 5v wires were reversed.

Suddenly, everything is working. I still don't get a transmit light on when on battery power, but it works. And, the 9V little battery works fine to drive this little app as well.

Sorry for the false alarm! At least I didn't break my Uno! -Pete

The TX light is driven by the USB to serial interface. If nothing is talking to the USB chip, it won't light up the LEDs.

Thanks for the info, James! I very much appreciate it! -Pete