Hi all,
Basically, i'm having issues trying to get my midi controller working, ive been searching for days and cant figure out whats going wrong.
with the code i have cobbled together, i can get 1 led responding to midi, although it sometimes does not respond
i also cant for the life of me get the second led to work at all, im not sure if im storing the serial values properly, i dont think the array is being updated. and the first leds unresponsiveness, i am nott 100% sure why its not working. any help on this would be fantastic.
#define MIDI_CHANNEL 1
byte incomingChannel[40]; //Read the incoming MIDI channel
byte incomingNote[40]; //Read the incoming MIDI note
byte incomingVelocity[40]; //Read the incoming note value
int ledStatus[40];
void setup()
{
Serial.begin (115200);
pinMode(A8,OUTPUT);
pinMode(A9,OUTPUT);
pinMode(A10,OUTPUT);
pinMode(A11,OUTPUT);
pinMode(A12,OUTPUT);
pinMode(A13,OUTPUT);
pinMode(A14,OUTPUT);
pinMode(A15,OUTPUT);
}
void loop()
{
{
if (Serial.available() > 2)
{
incomingChannel[1] = Serial.read();
incomingNote[1] = Serial.read();
incomingVelocity[1] = Serial.read();
if((incomingChannel[1]== MIDI_CHANNEL+143)&&(incomingNote[1]== 41)&&(incomingVelocity[1]==127))
{
ledStatus[1] = 1;
}
if((incomingChannel[1]== MIDI_CHANNEL+143)&&(incomingNote[1]== 41)&&(incomingVelocity[1]==0))
{
ledStatus[1] = 0;
}
{
if (ledStatus[1] == 1)
{
digitalWrite(A8,HIGH);
}
if (ledStatus[1] == 0)
{
digitalWrite(A8,LOW);
}
}
}
}
{
if (Serial.available() > 2)
{
incomingChannel[2] = Serial.read();
incomingNote[2] = Serial.read();
incomingVelocity[2] = Serial.read();
if((incomingChannel[2]== MIDI_CHANNEL+143)&&(incomingNote[2]== 42)&&(incomingVelocity[2]==127))
{
ledStatus[2] = 1;
}
if((incomingChannel[2]== MIDI_CHANNEL+143)&&(incomingNote[2]== 42)&&(incomingVelocity[2]==0))
{
ledStatus[2] = 0;
}
{
if (ledStatus[2] == 1)
{
digitalWrite(A9,HIGH);
}
if (ledStatus[2] == 0)
{
digitalWrite(A9,LOW);
}
}
}
}
} //VOID LOOP OUT