From there I've been using Hairless MIDI serial bridge and loopMidi as a MIDI server.
The code looks like this :
const int sensorPin = A0;
void setup(){
Serial.begin(9600);
}
void loop(){
int sensorVal = analogRead(sensorPin);
Serial.write(sensorVal);
//Serial.println(sensorVal);
delay(10);
}
So basically it uses a serial port at 9600 baud and the analog pin A0 as the input.
I found that the 10ms delay was the most stable solution, however I couldn't get it to map to Ableton Live or any soft synths for some reason.. the MIDI indicators did flash though and by accident I got an erratic movement on a mapped knob but that's about it.
With this method there's a lot of goofing around with the serial ports and the baud rates because if you try to alter the code and upload it the IDE will notify that the port is busy until you close the connections. (edit : the serial MIDI bridge is set to 115200 by default so that should be checked first..)
Any improvement ideas?
-ef
EDIT : I also found (using the serial plotter) that the pot is very unstable... what could be the cause for it?
EDIT 2 : The code is copied/modified from the TMP36/Love-o-meter code which is used to track temperature.
EDIT 3 : Fixed the code..
EDIT 4 : I've also been working on a logging script for Live in Powershell and I actually tried to get it writing a log file from the serial monitor but it didn't work..
EDIT 5 : Nevermind the ground connection; it's there to clear things up because I made the circuit on a breadboard.
EDIT 6 : I tried removing the Serial.println and it worked to some extent..
Here's an article I wrote on sending MIDI using an Arduino. It's still a work in progress, but the first four chapters (on the MIDI protocol, MIDI hardware, sending MIDI and MIDI controllers) are finished. If you want to use Hairless, you don't have to worry about the MIDI hardware, just make sure that the baud rate in your sketch matches your setting in Hairless.
First off the analogRead returns a number between 0 and 1023 and MIDI parameters are from 0 to 127.
Next you need to tell the MIDI that you are going to send controller messages on a specific channel. Then you need to tell it the controller message what number controller to use and finally you need to send the value of the controller.