Hi Everyone,
I just started working on a midi controller that's going to consist of 6 knobs for the moment. Right now I'm just trying to get one to work right before I move on to the other ones. I've done lots of reading around trying to find the best method and have came up with this:
•Duemilanove based Seeduino with a POT connected to analog 0.
•That's running the code that I put together based on a few different codes I found (code below)
•Then I'm using http://projectgus.github.com/hairless-midiserial/ to convert the Serial Data to MIDI
-
-
- I can map the POT to whatever I want to in Ableton Live, but that's where it stops working properly.
-
The problem is that it seems the POT wont go all the way from 0-127 for the value. It starts at about halfway. This happens with everything I map it to. I tried volume faders, panning, sends, and they all do the same. It seems the POT is going from 63-127 even if its turned all the way down. I also tried playing around with the division of the analog input values in the code but it keeps starting off at halfway.
I don't have any midi monitoring software I can run along with hairless-midiserial because I guess the serial ports can't be used with 2 apps at once. My question is, how can I calibrate the vaules of the POT so it falls into the whole range of 0-127. I saw an example code of how to autoscale variables but I couldn't figure out how to implement it into the code I'm using. I just want my knobs to go from 0-127 how they should. If anyone can help me out it would be much appreciated.
Thanks
code:
// Based on code by fabian at tubedogg.de 12/2006;
// and Benjamin Eckel
//This program reads up to 6 analog sensors / potentiometers and converts the data to Midi-Controller messages
// define Switchpin:
#define switchPin 10
// define LED:
#define LEDpin 13
// Variables
// define variables for the controller data
int currentPot[6] = {0,0,0,0,0,0};
// define the "lastValue" variables
int lastCurrentPot[6] = {0,0,0,0,0,0};
// select the midi Controller Number for each input
int midiCCselect[6] = {1,2,3,4,5,6};
// select threshold for each analog input
int thresh[6] = {1,1,1,1,1,1};
// select number of desired analog inputs (max 6)
int input_no = 1;
// sets up MIDI Channel
int midichannel = 0xB0;
void setup() {
// set the states of the I/O pins:
pinMode(switchPin, INPUT);
pinMode(LEDpin, OUTPUT);
// Set MIDI baud rate:
Serial.begin(115200); // I know it's higher than normal but my serial-midi converter requires it
}
// main program loop
void loop() {
for(int i=0; i<input_no; i++) {
currentPot[i] = analogRead(i) / 8;
if(abs(currentPot[i]-lastCurrentPot[i]) > i) {
midiCC(midichannel, midiCCselect[i], currentPot[i]);
lastCurrentPot[i] = currentPot[i];
//End if
}
//End for
}
//End Loop
}
// This function sends a Midi CC.
void midiCC(char CC_data, char c_num, char c_val){
Serial.print(CC_data, byte(0));
Serial.print(c_num, byte(0));
Serial.print(c_val, byte(0));
}