Alright, i have an Arduino Leonardo and I want to make a Arduino MIDI controller
because I need one, but I can't get it to work. I've downloaded some software and it works with the two pots i have. I also have a small keyboard that I want to use and it has a MIDI out, and I'm trying to send the serial data form the MIDI over the arduino to the PC (to the software that will later on turn this data into midi data that i can use with FL Studio or other programs) but it won't work. Now, this is the circuit tha I've came up with by using the parts that i have and by referencing other similar projects that I found on the web and the the code I wrote for it. Can someone explain me what's wrong with either one of them??
#include <SoftwareSerial.h>
//Analog pin ZERO
int valuePinZero=0;
int valuePinZero2=0;
//Analog pin ONE
int valuePinOne=0;
int valuePinOne2=0;
//Analog pin TWO
int valuePinTwo=0;
int valuePinTwo2=0;
byte commandByte;
byte noteByte;
byte velocityByte;
SoftwareSerial MIDIout(12,13);
void setup(){
MIDIout.begin(31250);
Serial.begin(31250);
while(!Serial){
;
}
}
void loop(){
checkMIDI();
valuePinZero = (analogRead(0)/8);
if (valuePinZero-valuePinZero2 >=2 || valuePinZero2-valuePinZero >=2) {
valuePinZero2 = valuePinZero;
MIDI_TX(176,75, valuePinZero);
//delay(100); //pour le debuggage
}
//————————
valuePinOne = (analogRead(1)/8);
if (valuePinOne - valuePinOne2 >=2 || valuePinOne2 - valuePinOne >=2)
{
valuePinOne2 = valuePinOne;
MIDI_TX(176,76, valuePinOne);
//delay(100);
}
//————————
valuePinTwo = (analogRead(2)/8);
if (valuePinTwo - valuePinTwo2 >=2 || valuePinTwo2 - valuePinTwo >=2)
{
valuePinTwo2 = valuePinTwo;
MIDI_TX(176,77, valuePinTwo);
//delay(100);
}
}
void MIDI_TX(unsigned char MESSAGE, unsigned char DONNEE1, unsigned char DONNEE2)
{
Serial.write(MESSAGE);
Serial.write(DONNEE1);
Serial.write(DONNEE2);
}
void checkMIDI(){
do{
if (MIDIout.available()){
commandByte = MIDIout.read();//read first byte
noteByte = MIDIout.read();//read next byte
velocityByte = MIDIout.read();//read final byte
Serial.write(commandByte);
Serial.write(noteByte);
Serial.write(velocityByte);
}
}
while (MIDIout.available() > 2);//when at least three bytes available
}
