# 1-5V scaling signal

I have search the forums. And did not find my answer. Sorry in advance if it was there.

I have a scale with measures 0-1300 LBS. It provides a 1-5V output signal.

How can make the arduino give the correct output weight? I cannot figure the scale for the 1-5V.

Assuming the scale in linear then use the map() function http://arduino.cc/en/Reference/Map
Something like lbs = map( V, 0, 1023, 0, 1300) where V is the value you read from the analogue input.

I would assume that because of the 1vdc 'zero offset' in your weight signal the mapping function should be setup as follows:

``````lbs = map( V, 205, 1023, 0, 1300);
``````

Lefty

TY worked well.

Curios is there a way to do this mathematically without mapping?

``````float lbs;
int v;

lbs = (float)(v-205) / (1024.0-205.0) * 1300.0;
``````

ninjay:
is there a way to do this mathematically without mapping?

All map() does is apply an offset and scale to the value you give it - in other words, it is implementing the 'mathematical' approach you mention (although I think you'll find that mathematicians refer to this as 'arithmetic').

ninjay:
Curios is there a way to do this mathematically without mapping?

From the map() reference link I supplied.

For the mathematically inclined, here's the whole function

long map(long x, long in_min, long in_max, long out_min, long out_max)
{
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}

Thanks retrolefty for pointing out my error, I really must read the posts properly 