// include the ResponsiveAnalogRead library
#include <ResponsiveAnalogRead.h>
const int A_PINS = 6; // number of Analog PINS
// define the pins you want to use and the CC ID numbers on which to send them..
const int ANALOG_PINS[A_PINS] = {A0,A1,A2,A3,A4,A5};
const int CCID[A_PINS] = {21,22,23,24,25,26};
// a data array and a lagged copy to tell when MIDI changes are required
byte data[A_PINS];
byte dataLag[A_PINS];
// ititialize the ReponsiveAnalogRead objects
ResponsiveAnalogRead analog[]{
{ANALOG_PINS[0],true},
{ANALOG_PINS[1],true},
{ANALOG_PINS[2],true},
{ANALOG_PINS[3],true},
{ANALOG_PINS[4],true},
{ANALOG_PINS[5],true},
{ANALOG_PINS[6],true}//,
//{ANALOG_PINS[7],true},
//{ANALOG_PINS[8],true},
}; // not sure if there is a better way... some way run a setup loop on global array??
void setup() {
// begin serial so we can see analog read values through the serial monitor
//Serial.begin(9600);
}
void loop() {
// update the ResponsiveAnalogRead object every loop
for (int i=0;i<A_PINS;i++){
analog[i].update();
// if the repsonsive value has change, print out 'changed'
if(analog[i].hasChanged()) {
data[i] = analog[i].getValue()>>3;
if (data[i] != dataLag[i]){
dataLag[i] = data[i];
usbMIDI.sendControlChange(CCID[i], data[i], 1);
}
}
}
}