pressure sensor range problem

Hello,
I am still very new to using Arduino boards, and I am currently using an Uno to read the analog input from a pressure transducer.
I am able to read the voltage properly but having a problem mapping the sensor voltage to psi.
my sensor range is: 0.5-4.5V linear voltage output. 0 psi outputs 0.5V, 250 psi outputs 2.5V, 500 psi outputs 4.5V.
any help will be greatly appreciated.

The problem is on line 147 of the code you didn't show us.

Please use [ code ] tags.

I am able to read the voltage properly but having a problem mapping the sensor voltage to psi.

Is the mysterious sensor's output linear?

What problem(s) are you having?

The output is linear. See attached plot, and linear fit.

Is this a good time to mention the reviled map() function?

Rather than use the reviled map() function, I would add one line to the program, as follows:

float psi = volts*125.0 - 62.5;

The range for the voltage is 4V (0.5 to 4.5), which is for a pressure range of 500psi (0 psi to 500 psi).
That means that the measured voltage at the Arduino pin must corrected for the offset, and after that be divided by 4V and multiplied with 500psi.

I prefer to calculate the voltage at the Arduino pin first, and after that calculate the pressure.

int rawADC = analogRead(A0);
float voltage = (float) rawADC * 5.0 / 1024.0; // divided by raw data range, multiplied by voltage range
float psi = (voltage - 0.5) / 4.0 * 500.0;    // minus offset, divided by voltage range, multiplied by pressure range.

Its a ratiometric sensor, the voltage shouldn't come into it:

float ratio = (analogRead (A0) + 0.5) / 1024.0 ;  // 0 to 1 range
float pressure_PSI = (ratio - 0.1) * 500.0 / 0.8 ;