I am working on a program that adjusts a throttle value based off of an accelerometer reading to keep a vehicle from giving the rider any side accelerations. The problem I am having is when I try to map the accelerometer values into values from 0-255 to use for adjusting the throttle I get an output of -1 .
This is how I setup the command
The map function doesn't work well with float values, so what you can do is multiply ax by 10, 100 or even 1000 to give you a better range. Likewise the Low and High ranges must be changed too.
I'm not really sure why everyone seems to think that map() is the only way to accomplish a job. Since you have the same lower limit for each range, a simple multiplication is all that is needed.
Paying attention to argument types would be helpful, too.