Hi there,
So far I have set up code that allows my arduino work as a usb midi device (Using HIDUINO). However, the analog inputs are constantly sending data which makes it impossible to assign them within DAWs such as Logic Pro. I have no idea how to do this and how to add it to my code
Here is the code, there are 6 analog potentiometer inputs I am using:
#include <MIDI.h>
MIDI_CREATE_DEFAULT_INSTANCE();
int mem = { 0, 0, 0, 0, 0, 0, };
// Variables:
int cc = 0;
int AnalogValue = 0; // define variables for the controller data
int lastAnalogValue = 0; // define the “lastValue” variables
int inVal = analogRead(0);
int outVal = map(inVal, 94, 555, 0, 127);
void setup()
{
MIDI.begin(MIDI_CHANNEL_OMNI);
Serial.begin(9600);
pinMode(1, INPUT_PULLUP);
}
void loop() {
AnalogValue = analogRead(0);
// convert to a range from 0 to 127:
cc = AnalogValue;
// check if analog input has changed
if (lastAnalogValue != cc) {
MIDI.sendControlChange(16,cc,1);
// update lastAnalogValue variable
lastAnalogValue = cc;
AnalogValue = analogRead(1);
// convert to a range from 0 to 127:
cc = AnalogValue/8;
// check if analog input has changed
if (lastAnalogValue != cc) {
MIDI.sendControlChange(17,cc,1);
// update lastAnalogValue variable
lastAnalogValue = cc;
AnalogValue = analogRead(2);
// convert to a range from 0 to 127:
cc = AnalogValue/8;
// check if analog input has changed
if (lastAnalogValue != cc) {
MIDI.sendControlChange(18,cc,1);
// update lastAnalogValue variable
lastAnalogValue = cc;
} // endif
AnalogValue = analogRead(3);
// convert to a range from 0 to 127:
cc = AnalogValue/8;
// check if analog input has changed
if (lastAnalogValue != cc) {
MIDI.sendControlChange(19,cc,1);
// update lastAnalogValue variable
lastAnalogValue = cc;
} // endif
AnalogValue = analogRead(4);
// convert to a range from 0 to 127:
cc = AnalogValue/8;
// check if analog input has changed
if (lastAnalogValue != cc) {
MIDI.sendControlChange(20,cc,1);
// update lastAnalogValue variable
lastAnalogValue = cc;
} // endif
AnalogValue = analogRead(5);
// convert to a range from 0 to 127:
cc = AnalogValue/8;
// check if analog input has changed
if (lastAnalogValue != cc) {
MIDI.sendControlChange(21,cc,1);
// update lastAnalogValue variable
lastAnalogValue = cc;
} // endif
}
}
}