Can't Calibrate Pots To Go From 0-127

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));

}

How have you got the pot wired up?
One end to +5V other end to ground and the central wiper to the input.
If you only have one pot connected but are reading the other inputs then you need to connect the unused inputs to ground.
Do you have a linear pot? You might get this effect if you have a log pot.

Mike, if it wasn't for you asking me about the kind of pot I'm using I wouldn't have realized that I left a 10k resistor on the ground of the POT from another circuit I was messing around with. DOH!!! Thanks for help anyways :slight_smile:

A couple of questions:

  1. What type of pots (linear-taper or audio-taper)?
  2. Why not use the map() function...?

cr0sh:
A couple of questions:

  1. What type of pots (linear-taper or audio-taper)?
  2. Why not use the map() function...?

He's got the problem fixed already. :stuck_out_tongue:

But as for not using map(), it makes much more sense to simply divide, since the analogRead range is a power of 2 times the MIDI value range.