hold last sensor value

Grumpy_Mike:
Yes do you mean something like this:-

tempVal = analogRead(posPin);

if(tempVal !=0) posVal = tempVal;

yey! this works:

void loop(){
    delay(30);
    readPos();
    MIDI.sendControlChange(22, posVal, 16);
}

void readPos(){
  tempVal = analogRead(posPin);
  if(tempVal !=0) {
  posVal = tempVal;
  posVal = map(posVal, 1023, 1, 127, 0);
  posVal = constrain(posVal, 0, 127);
}
}