// Variables: int input_nb = 1; // select number of desired analog inputs (max 6) int AnalogValue[2] = {0}; // define variables for the controller data int lastAnalogValue[2] = {0}; // define the "lastValue" variables int midiCCselect[2] = {22}; // select the midi Controller Number for each input (22 to 31 are free) int thresh[2] = {1}; // select threshold for each analog input void setup() { // Set MIDI baud rate: Serial.begin(31250); // 31250 } void loop() { for (int i =0; i < input_nb; i++) { // My potentiometer gave a range from 0 to 1023: AnalogValue[i] = analogRead(i); // convert to a range from 0 to 127: int cc = AnalogValue[i]/8; // check if analog input has changed if (cc != lastAnalogValue[i] ) { //send control change on cc#i midiCC(0xB0, midiCCselect[i], cc); //Serial.println(String(midiCCselect[i])+": "+String(cc)); // update lastAnalogValue variable lastAnalogValue[i] = cc; } } // endfor } // sends a Midi CC. void midiCC(byte CC_data, byte c_num, byte c_val){ Serial.write((byte)CC_data); Serial.write((byte)c_num); Serial.write((byte)c_val); }