MIDI + Arduino + USB

MIDI+Arduino+USB project gives you a physical MIDI trigger button with USB.

Below you’ll find the links required to turn an Arduino into a MIDI device. The Arduino code I used to send MIDI notes, I was not able at the time of this posting to send MSC with Moco for LUFA, I’m still working on a fix. Below the code I have some photos of the box. Enjoy.

 How to make an Arduino into a MIDI device:

http://arduino.cc/en/Hacking/DFUProgramming8U2

Moco for LUFA

Arduino Code:

// MSC MIDI Arduino controller
// By Dave Mickey, myMIDIremotes
int buttonPin5 = 12; //Stop
int buttonPin4 = 11; //Reset
int buttonPin3 = 10; //Prev
int buttonPin2 = 9; //Next
int buttonPin1 = 8; //GO
int ledPinON = 2; //LED states that the code loaded correctly
int ledPinMIDI = 3; //LED states that the MIDI was sent

// variables will change:
int buttonState1 = 1;
int buttonState2 = 1;
int buttonState3 = 1;
int buttonState4 = 1;
int buttonState5 = 1;

void setup() {
Serial.begin(31250); // Set serial to the MIDI baud rate of 31250
pinMode(ledPinMIDI, OUTPUT);
pinMode(ledPinON, OUTPUT);
pinMode(buttonPin1, INPUT);
pinMode(buttonPin2, INPUT);
pinMode(buttonPin3, INPUT);
pinMode(buttonPin4, INPUT);
pinMode(buttonPin5, INPUT);
digitalWrite(ledPinON, HIGH);
digitalWrite(ledPinMIDI, HIGH);
delay(500);
digitalWrite(ledPinMIDI, LOW);
}

void loop() {
buttonState1 = digitalRead(buttonPin1);
buttonState2 = digitalRead(buttonPin2);
buttonState3 = digitalRead(buttonPin3);
buttonState4 = digitalRead(buttonPin4);
buttonState5 = digitalRead(buttonPin5);

if (buttonState1 == 0) {
digitalWrite(ledPinMIDI, HIGH);
Serial.write(0x90);
Serial.write(0x01);
Serial.write(0x00);
delay(250);
digitalWrite(ledPinMIDI, LOW);
buttonState1 = 1; //reset to look for the next input
}

if (buttonState5 == 0) {
digitalWrite(ledPinMIDI, HIGH);
Serial.write(0x90);
Serial.write(0x02);
Serial.write(0x00);
delay(250);
digitalWrite(ledPinMIDI, LOW);
buttonState5 = 1; //reset to look for the next input
}
if (buttonState2 == 0) {
digitalWrite(ledPinMIDI, HIGH);
Serial.write(0x90);
Serial.write(0x03);
Serial.write(0x00);
delay(250);
digitalWrite(ledPinMIDI, LOW);
buttonState2 = 1; //reset to look for the next input
}

if (buttonState3 == 0) {
digitalWrite(ledPinMIDI, HIGH);
Serial.write(0x90);
Serial.write(0x04);
Serial.write(0x00);
delay(250);
digitalWrite(ledPinMIDI, LOW);
buttonState3 = 1; //reset to look for the next input
}

if (buttonState4 == 0) {
digitalWrite(ledPinMIDI, HIGH);
Serial.write(0x90);
Serial.write(0x05);
Serial.write(0x00);
delay(250);
digitalWrite(ledPinMIDI, LOW);
buttonState4 = 1; //reset to look for the next input
}
//End Loop
}

 Photos:

It works

It works

 

the adafruit pshield

the adafruit pshield

 

putting it all together

putting it all together

Qlab Screen shot

Qlab Screen shot

Video Link:  MIDIbox