500mm softpot range

Hi Guys

i did a midi ribbon controller using Arduino and 500mm softpot based on this idea ..

output MIDI Note ON/OFF and Pitch Bend control signals when a ribbon/softpot variable potentiometer is adjusted. When the ribbon/softpot is pressed a MIDI Note On message is transmitted. While it is still pressed a MIDI Pitch Bend message is sent if the finger is moved. When the finger is removed the MIDI Note Off message is transmitted.

everything works great using this code..

/**********************************************************
 * NAME:                 Ribbon/Softpot Controller forSound Generation via MIDI
 * WRITTEN BY:           TOM SCARFF
 * DATE:                 20/2/2009
 * FILE SAVED AS:        midi_ribbon_controller.pde
 * FOR:                  Miduino ATmega168
 * CLOCK:                16.00 MHz CRYSTAL                                        
 * PROGRAMME FUNCTION:   Trigger a MIDI Sound,
 * depending on ribbon/softPot voltage level when pushed,
 * and generate Pitch Bend while Note is ON.
 * 
 **************************************************************************/




// analog Thresholds for softPot sensing
#define softPotThreshold_ON 100
#define softPotThreshold_OFF 10
#define startNote  60
#define Bounce_Period 15
#define Pitch_Bend_Sensitivity 2
#define Program 50

int softPotPin = 0;                 // softPot connected to analog pin 0
int LedPin = 13;                // LED connected to digital pin 13
byte softPotState=0;
byte x;
byte MIDIchannel;
byte velocity=127;
byte note_onoff;
int bend;
int val_noteOn;
int val_now=0x7f;
int val;

void setup()                    // run once, when the sketch previouss
{
  pinMode(4, INPUT); // Set Inputs for 4 way DIP Switch
  pinMode(5, INPUT); 
  pinMode(6, INPUT); 
  pinMode(7, INPUT); 
  digitalWrite(4, HIGH); // Set inputs Pull-up resistors High
  digitalWrite(5, HIGH);
  digitalWrite(6, HIGH);
  digitalWrite(7, HIGH);

  Serial.begin(31250);
  pinMode(LedPin, OUTPUT);      // sets the digital pin as output

  for (x=1; x<=4; x++){
    digitalWrite( LedPin, HIGH );
    delay(300);
    digitalWrite( LedPin, LOW );
    delay(300);
  }

  midiSend( 0xC0 | MIDIchannel, Program );
}

void loop()                     // run over and over again
{
  // Read 4-way DIP switch
  MIDIchannel=digitalRead(4) + (digitalRead(5)<<1) + (digitalRead(6)<<2) + (digitalRead(7)<<3);

  val = analogRead(softPotPin); // read voltage on analog pin 0

  if( val >= softPotThreshold_ON  && softPotState==0) {

    note_onoff=val/64 + startNote;  //  0 to 15 + 60
    noteOn(MIDIchannel,  note_onoff, velocity);
    softPotState=0xff;

    pitch_bend_test();

  }


  if( val <= softPotThreshold_OFF  && softPotState>0 ) {
    noteOff(MIDIchannel,  note_onoff, velocity);
    softPotState=0;
  }

  delay(Bounce_Period);
}


//++++++++++++++++++++++Functions++++++++++++++++++++++++++++++++++++++++

// Send a MIDI note-on message.  
void noteOn(byte channel, byte note, byte velocity) {
  midiMsg( (0x90 | channel), note, velocity);
}

// Send a MIDI note-off message. 
void noteOff(byte channel, byte note, byte velocity) {
  midiMsg( (0x80 | channel), note, velocity);
}

// Send a MIDI Pitch bend  message.  
void pitch_bend(byte channel, byte LSB, byte MSB) {
  midiMsg( (0xE0 | channel), LSB, MSB);      // set LSB = 0
}

//  Send a two byte midi message  
void midiSend(byte status, byte data ) {
  Serial.print(status, BYTE);
  Serial.print(data, BYTE);
}

// Send a general MIDI message
void midiMsg(byte cmd, byte data1, byte data2) {
  digitalWrite(LedPin,HIGH);  // indicate we're sending MIDI data
  Serial.print(cmd, BYTE);
  Serial.print(data1, BYTE);
  Serial.print(data2, BYTE);
  digitalWrite(LedPin,LOW);
}
//------------------------------------------------------------------

void pitch_bend_test(){

  val_noteOn = analogRead(softPotPin)/Pitch_Bend_Sensitivity; // read voltage on analog pin 0 range 0 to 1023


  while(val >= softPotThreshold_ON){
    val_now = analogRead(softPotPin)/Pitch_Bend_Sensitivity; // read voltage on analog pin 0 range 0 to 1023

    if(val_now > val_noteOn){
      bend = (val_now - val_noteOn) + 64;
      bend = bend & 0x007F;
      pitch_bend(MIDIchannel,0x00, bend); 
    }

    if(val_now < val_noteOn){
      bend = 64 - (val_noteOn - val_now);
      bend = bend & 0x007F;
      pitch_bend(MIDIchannel,0x00, bend); 
    }

    delay(Bounce_Period); 
    val = analogRead(softPotPin); // read voltage on analog pin 0 
  }

}


//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

the only thing that not working as i expected is the 500mm softpot.
if i press from the right side of the softpot and slide my finger to the left i get pitch bend but after 10cm its start from the beginning (high to low note), its not ends with the end of the softpot, it ends earlier and start over.

my question is what can i do to have the whole scale of the 500mm softpot? meaning.. right position of the sofpot (highest tone) to left position of softpot (lowest tone), but to the whole length of the softpot, if using VSTI for example from C0 to C8.
PS the softpot is 17.22k

thanks in advance,
Isak E.