Get velocity from Pressure Sensor

Hi guys! What's up?!

I really need your help because I'm freaking out on this point!

My goal is: to get the pressure of a Force Sensitive Resitor (Pressure Sensor) and use it as velocity for a MIDI note.

I already did this:

thumblval = analogRead(thumb);
if(thumbval>50)
{

if(a==0){
noteOn(0x90,int(43),127);
a=1;
}
}
else{
if(a==1){
noteOn(0x90,int(43),0);
a=0;
}
}

*43 is the note, >50 is the lowest value limit, 127 and 0 are the two velocity that I associated to have the NoteOn - NoteOff effect.

This code works perfectly but as you can see the velocity in output is always 127. Every other test i did gives some problems like: continuous triggers of the note or something like that.

I just need to associate to one note one velocity value and the input should stop only when I stop pushing (with the velocity being steady during that time).

I hope I was clear enough and I say thanks in advance to everybody out there!

Ciao!

Try replacing 127 with thumbval:

code

noteOn(0x90,int(43),thumbval);

And one more thing. After reading thumbval, constrain it to 127 or less:

if thumbval > 127
   thumbval =127;

.... I'm not 100% sure that will work, but it might help.