hold last sensor value

PaulS:

I need it to stay on the last value it read.

That's exactly what it is doing. The last value that it read was a 0. You need to be a little clearer in your requirements.

Sorry if I was unclear,

Its a 50 cm position sensor and if I press it in the middle and get a value of perhaps 60, I would like the MIDI.sendControlChange to keep sending 60. Until I press again somewhere else and update the "last pressed value".

Thanks