problem using arduino as midi

Hi folks! This is my first arduino project, zo I am a novice to using the arduino. I want to use arduino as an interface for midi-control. I made I really simple setup. I use a piezobutton and connect a midi cable to the arduino board. This goes in the midi-in from my emu 0404 pci soundcard. In reason, cubase, FM7 or midi ox it isn't showing any signal. It would be great if someone could help me out!

In arduino I used the following code: /* * Convert Arduino to a MIDI controller using 1 digital input. * * This sketch is set up to send 1 MIDI notes on MIDI channel 1,


// define the pins we use int switchPin1 = 8;

// general midi notes char note1 = 60; //Middle C char note2 = 62; //D char note3 = 64; //E char note4 = 65; //F char note5 = 67; //G char note6 = 69; //A

// Variables int switchState1 = LOW;

int currentSwitchState1 = LOW;

void setup() {

// set the states of the I/O pins: pinMode(switchPin1, INPUT);

// set MIDI baud rate : Serial.begin(31250);


void loop() {

//switchPin1 currentSwitchState1 = digitalRead(switchPin1); if( currentSwitchState1 == LOW && switchState1 == HIGH ) // push //Note on channel 1 (0x90), some note value (note), middle velocity (0x45): noteOn(0x90, note1, 0x45); if( currentSwitchState1 == HIGH && switchState1 == LOW ) // release //Note on channel 1 (0x90), some note value (note), silent velocity (0x00): noteOn(0x90, note1, 0x00); switchState1 = currentSwitchState1;


// Send a MIDI note-on/off message. void noteOn(char cmd, char data1, char data2) { Serial.print(cmd, BYTE); Serial.print(data1, BYTE); Serial.print(data2, BYTE); }

The code looks OK although I would like to see curly braces after the if. However you are only doing the one instruction so that's OK.

So it is probably down to the hardware. How are you wiring that up? Many people get the two signals the wrong way round.

I have the exact same hardware setup as you (down to the emu 0404), and I had some difficulties too. Turned out I had 2 midi pins connected wrongly. Could you post the schematics?

I use 5v and the gnd. from 5v to the button then from the other side of the button one cable to the ground and one cable to 10Kohm resistor and from the resistor to digital 8.

The midi jack. Looking from the back with the pins under (like a smile) The TX is connected to the fourth pin from the left. The gnd in the middle 5v on the second pin from the left

This midi jack I put in the midi-input of my soundcard

This might help. It's a blog on wiring a Arduino to output MIDI:


Sounds to me like you connected the arduino to pins 1 and 3 instead of 4 and 5 ;)

Thanx for the reactions. :) I described the making of the midi jack wrongly but corrected it. I just built the Midi output from roguescience.... and this one worked:)) So finally I make connection. So it seems there was something wrong in the code .

Nice. What are you building?

I want to use an infrared sensor to control a knob on my virtual soft synth. So I am experimenting with the midi language. But I still don't get it yet. The midi-output I build is not stable, it keeps on giving messages. I have to understand better what this midi-signal consists of. It is hard to find proper info on the internet. Then I have to understand the arduino langauge better. Well enough work to do. If you got any idea where or how.... :)

I don't fully understand the problem (or cause of the problem) you have, but I can recommend you one thing. Right now I see you're doing MIDI communication yourself, and there's nothing wrong with that, but there's a nice MIDI library at the arduino playground that has some nice stuff builtin: It might not solve the problems you currently have, but it provides a nice and clean implementation of MIDI and takes away all the serial code and stuff you have there now :)

I want to make a midi-controller. It seems that this midi-library is only useful if I want to use arduino as midi-input? Or do I misunderstand?