- Code: Select all | TOGGLE FULL SIZE
float mAval = (raw1*20)/1024;
All the terms in your expression are integers. Try making the multiplier a floating point number as in the example I provided.
What's happening is that all the arithmetic on the right side of the '=' is being done as integer arithmetic, so you're losing the fractional part. The conversion to floating point is done
after the calculation is completed. By using 20.0 for your multiplier, you are forcing the compiler to convert raw1 to floating point
before the multiply and divide operations are executed.