Hello!, I am building a very simple midi controller, with 5 potentiometers (one for each analog in)
I have based on this:
and on this code:
void setup()
{
Serial.begin(31250); // Default speed of MIDI serial port
pinMode(13, OUTPUT); // Light LED on pin 13 to notify of readynes
digitalWrite(13, HIGH);
}
int iAn0Val, iAn1Val;
void loop()
{
//Slider X
int iAn0ValPrev = iAn0Val; //Get the previous value of slider X
iAn0Val = analogRead(0)/8;
analogPinMidiTX(1,iAn0Val,iAn0ValPrev); //TX the value of slider X
//Slider Y
int iAn1ValPrev = iAn1Val; //Get the previous value of slider Y
iAn1Val = analogRead(1)/8;
analogPinMidiTX(2,iAn1Val,iAn1ValPrev); //TX the value of slider Y
}
void analogPinMidiTX(int iChan, int iVal, int iValPrev)
{
//only TX the value over midi if it is changed, as to prevent spamming the midi port and thus confusing the receiving application in learning mode
if(iValPrev != iVal)
{
MidiTX(176,iChan,iVal);
}
}
void MidiTX(unsigned char MESSAGE, unsigned char CONTROL, unsigned char VALUE) //pass values out through standard Midi Command
{
Serial.print(MESSAGE);
Serial.print(CONTROL);
Serial.print(VALUE);
}
The problem is that the code is made for been used with 2 potentiometers, and I want to connect 5. How can I fix the code for using it with 5 potentiometers?
Sorry for my bad english