I've been trying to make a MIDI controller for a school project, just a simple 4 button 4 knob controller but I've stumbled into some problems with the code.
I had to add the bounce and midi libraries to my project, but know I'm getting an error saying:
Arduino: 1.8.7 (Windows Store 1.8.15.0) (Windows 10), Board: "Arduino/Genuino Uno"
C:\Users\KVON\AppData\Local\Temp\Temp2_DJTT_DIY_MIDI.ino_.zip\DJTT_DIY_MIDI\DJTT_DIY_MIDI.ino: In function 'void loop()':
DJTT_DIY_MIDI:63:15: error: 'class USBMIDI_' has no member named 'sendControlChange'
USBMIDI.sendControlChange(i, ccValue*, 3);*
I get this error for each line including "USBMIDI.sendControlChange. I've been trying to figure out how to fix this but I'm pretty stumped.
I've attached the rest of my code below, if anyone has any ideas I'd really appreciate it if you could leave a reply
Thanks Loads
```
*#include <Bounce2.h>
#include <usbmidi.h>
// define how many pots are active up to number of available analog inputs
#define analogInputs 4
// make arrays for input values and lagged input values
int inputAnalog[analogInputs];
int iAlag[analogInputs];
// make array of cc values
int ccValue[analogInputs];
// index variable for loop
int i;
// cc values for buttons
int cc_off = 0;
int cc_on = 65;
int cc_super = 127;
// map buttons to cc for button
int cc0 = 51;
int cc1 = 52;
int cc2 = 53;
int cc3 = 54;
Bounce button0 = Bounce(0, 3);
Bounce button1 = Bounce(1, 3);
Bounce button2 = Bounce(2, 3);
Bounce button3 = Bounce(3, 3);
void setup() {
// MIDI rate
Serial.begin(31250);
pinMode(0, INPUT_PULLUP);
pinMode(1, INPUT_PULLUP);
pinMode(2, INPUT_PULLUP);
pinMode(3, INPUT_PULLUP);
pinMode(4, INPUT_PULLUP);
pinMode(5, INPUT_PULLUP);
pinMode(6, INPUT_PULLUP);
pinMode(7, INPUT_PULLUP);
pinMode(8, INPUT_PULLUP);
pinMode(9, INPUT_PULLUP);
pinMode(10, INPUT_PULLUP);
pinMode(11, INPUT_PULLUP);
}
void loop() {
// loop trough active inputs for knobs
for (i=0;i<analogInputs;i++){
// read current value at i-th input
inputAnalog[i] = analogRead(i);
// if magnitude of difference is 8 or more...
if (abs(inputAnalog[i] - iAlag[i]) > 7){
// calc the CC value based on the raw value
ccValue[i] = inputAnalog[i]/8;
// send the MIDI
USBMIDI.sendControlChange(i, ccValue[i], 3);
// set raw reading to lagged array for next comparison
iAlag[i] = inputAnalog[i];
}
delay(5); // limits MIDI messages to reasonable number
}
// Push Button code
button0.update();
button1.update();
button2.update();
button3.update();
if (button0.fallingEdge())
{
USBMIDI.sendControlChange(cc0, cc_on, 3);
}
if (button1.fallingEdge())
{
USBMIDI.sendControlChange(cc1, cc_on, 3);
}
if (button2.fallingEdge())
{
USBMIDI.sendControlChange(cc2, cc_on, 3);
}
if (button3.fallingEdge())
{
USBMIDI.sendControlChange(cc3, cc_on, 3);
}
if (button0.risingEdge())
{
USBMIDI.sendControlChange(cc0, cc_off, 3);
}
if (button1.risingEdge())
{
USBMIDI.sendControlChange(cc1, cc_off, 3);
}
if (button2.risingEdge())
{
USBMIDI.sendControlChange(cc2, cc_off, 3);
}
if (button3.risingEdge())
{
USBMIDI.sendControlChange(cc3, cc_off, 3);
}
}*
```