hold last sensor value

I don't really understand what you are doing.

Me neither, hence my posting in the forum "programming questions" :slight_smile:

    posVal = tempVal;

posVal = map(posVal, 1023, 1, 127, 0); // make midi notes
    posVal = constrain(posVal, 0, 127); // constrain it



Why? You never use posVal anywhere else.

Its a remain from previous iterations. Does it matter?

If tempVal is not 0, how can it be anything other than not 0? The 2nd if statement should be an else.

This what always confuses me. the logic of if's and else's. I cant figure it out :frowning: