(Solved) Pitch Bend over serial problem

I am trying to send pitchbend data mapped from a pot connected to A0 input.
I have my sketch looping reading the pot and then remapping the value to be inside 127. Then I output 3 bytes, 1st byte is the pitchbend command 224, MSB and LSB are set to be the same.

But when i use Hairless Midi to convert serial to MIDI to be used in Cubase, I am recieving program changes and no pitch bend data. What could be the problem?
Here is my sketch file:

void setup() {
  Serial.begin(32150);
}

void loop() {
  int sensorValue = analogRead(A0);
  sensorValue=map(sensorValue, 0, 1023, 0, 127);
  Serial.print(224);
  Serial.print(sensorValue);
  Serial.print(sensorValue);
}
  sensorValue=map(sensorValue, 0, 1023, 0, 127);

That's a pretty expensive way to divide by 8.

  Serial.print(224);
  Serial.print(sensorValue);
  Serial.print(sensorValue);

You are sending strings, with no delimiters. I'm pretty sure you are supposed to be sending binary data, with write().

Thanks for the reply PaulS.
So from your reply, I have understood that you are saying toreplace the Serial.print() functions with Serial.write() as shown:

void setup() {
  Serial.begin(32150);
}

void loop() {
  int sensorValue = analogRead(A0);
  sensorValue=map(sensorValue, 0, 1023, 0, 127);
  Serial.write(224);
  Serial.write(sensorValue);
  Serial.write(sensorValue);
}

Still no midi pitch bend data...

That's a strange baud rate you are using. Every other MIDI program I've seem use 31250, not 32150.

And that is the extent of my knowledge of MIDI.

Thanks PaulS.

My mistake, it was a typo, I have corrected to the baud rate of 31250 and still not recieving pitch bend message out of Hairless serial to midi.

PaulS, I thank you greatly. I was such an idiot, I had Cubase filtering pitchbend data so that's why it was not recieving it. Indeed after trying your suggestion of using the serial.write function, IT WORKS A CHARM! Many thanks.

I was such an idiot, I had Cubase filtering pitchbend data so that's why it was not recieving it.

Yep, that qualifies you for membership.