I've been trying to set one knob on the Arduino Uno to control a parameter on Ableton Live.
I've been revising tutorials and stuff on this forum and others, but I'm still stuck.
I have a potentiometer on pin 0, I'm using the MIDI Library, the serial messages go through Hairless and I have MIDI Monitor to see whats happening. The MIDI messages go through IAC Bus 1.
What I have accomplished so far is having the board send MIDI Messages. What messages it is sending is confusing since MIDI Monitor tells me different things, from note on/off to pitchbend and other invalid commands whenever I twist the knob.
This is my code:
#include <MIDI.h>
#include <midi_Defs.h>
#include <midi_Message.h>
#include <midi_Namespace.h>
#include <midi_Settings.h>
MIDI_CREATE_DEFAULT_INSTANCE();
int sensorPin = 0;
int ledPin = 9;
int sensorValue = 0;
int sensorValuePrev = 127;
void setup()
{
Serial.begin(9600); // Default speed of MIDI serial port
pinMode(ledPin, OUTPUT);
MIDI.begin(1);
}
void loop() {
fade();
sensorValue = analogRead(0)/4;
if((sensorValue - sensorValuePrev) > || (sensorValue - sensorValuePrev) < -1) {
if(sensorValue != sensorValuePrev) {
MIDI.sendControlChange(1, sensorValue, 1);
sensorValuePrev = sensorValue;
}
}
}
void fade() {
// read the value from the sensor:
sensorValue = analogRead(sensorPin)/4;
// turn the ledPin sensorValue
analogWrite(ledPin, sensorValue);
}
There is an LED. It's brightness changes depending according to the knob.
The goal for this small project is to build a controller with a bunch of knobs. I would appreciate if the comments and advises would go in that direction in the sense that i would prefer if I don't have to use a Serial to MIDI converter.
This is the first time I'm posting something here. Let me know if i'm not being specific enough or if i'm missing something.