Arduino + MIDI + FLStudio

Hey guys,

absolute newbie here. We use arduino for a schoolproject, and i want to make myself a MIDI controller, basically. It has to communicate with Fruityloops. That’s all working (I use S2midi, since this is only a prototype, the definitive machine will have a better MIDI interface). That works, I got my analog inputs working too. But, I want to use the digital inputs as well, some of them will be pushbuttons, others switches, but they all have the same basic action: ON/OFF

And I just can’t get it to work. I’ve tried anything, which means I’m probably looking in all the wrong places.

// Arduino MULTI MIDI CC script

int inputsAnalog = {0, 1, 2, 3, 4, 5};
int channelsAnalog = {9, 10, 11, 12, 13, 14};
int lastAnalogs= {0, 0, 0, 0, 0, 0};

int inputsDigital = {3, 4, 5, 6, 7, 8};
int channelsDigital = {15, 16, 17, 18, 19, 20};
int lastDigital= {LOW, LOW, LOW, LOW, LOW, LOW};

int analogSmooth = 2;

void setup()

void loop()
for (int i=0; i<2; i++)
doReadAnalog(i, inputsAnalog, channelsAnalog_, lastAnalogs*);
} *_

* for (int i=0; i<2; i++)*
* {*
doReadDigital(i, inputsDigital_, channelsDigital*);
void doReadAnalog(int i, int input, int channel, int lastAnalog)
int readingAnalog = 0;
readingAnalog = analogRead(input)/8;
if (abs(readingAnalog-lastAnalog) > analogSmooth)
lastAnalogs = readingAnalog;
controlChange(channel, 10, readingAnalog);
void doReadDigital(int i, int input, int channel)
int readingDigital = 0;
readingDigital = digitalRead(input);*_

_ if(lastDigital != readingDigital)
* {
if(readingDigital == ‘HIGH’)
controlChange(channel, 10, 0);
controlChange(channel, 10, 127);
lastDigital = readingDigital;
// Send a MIDI control change*

void controlChange(byte channel, byte controller, byte value)
* midiMsg(channel+0xB0, controller, value);
// Send a general MIDI message*

void midiMsg(byte cmd, byte data1, byte data2)
* Serial.print(cmd, BYTE);
Serial.print(data1, BYTE);
Serial.print(data2, BYTE);

Anyway, that’s the code I got…When I use this the analog works, it recognizes the digital input, but the midi message probably isn’t right so it sends the same value for HIGH and LOW. Please help me with this, deadlines are approaching…
thanks in advance…_

PS. I'm not trying to send NoteOn/NoteOff, at least I don't think I am. I want the button to activate or mute an effect or channel. I know there are different types of ControlChange messages, so it could be down to that.

If you are using MIDI the standard Baud rate is 31250. So use:


Thanks for the reply. What difference does that make?? I wouldn't know. I've seen other MIDI scripts use that 31250, but this baud rate works too. I'm gonna try it today, see what it does.

I got the script to work, stupid mistake.
if(readingDigital == 'HIGH')
should be
if(readingDigital == HIGH)
haha, i saw that error so many times i didn't see it anymore.

But now, I have another problem. I want to do 4 digital inputs, but when I got it all connected (identical buttons, wires and resistors), it only reads the first two somehow. Anyone know why that might be?