Regarding the following code:
mpu.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
ax = map(ax, -17000, 17000, -1500, 1500);
I know the reason for taking 17000 as value - that's 1g. But I am not getting how and why 1500 value is taken.
1 Answer 1
The map()
function is well explained here.
In short, it maps one range of numbers to another. In this case it will map ax
from the range (-17000:17000) into the range (-1500:1500).
Imagine a ruler with both inches and cm on. If you have a measurement in inches, you can represent that same measurement (point on the ruler) in cm. Your "ruler" here has one scale ranging from -17000 to 17000, and another scale ranging from -1500 to 1500. You're finding the reading on the second side at the point ax
on the first.
If you mean specifically why are those numbers used -- then I have no idea since you give no context.
-
.Thanku so much. now i understood. your exampple of ruler just nailed it.user3605647– user36056472017年01月06日 19:12:43 +00:00Commented Jan 6, 2017 at 19:12
-
You're welcome. If the answer was helpful you can accept it and optionally up-vote it :-)Mark Smith– Mark Smith2017年01月06日 19:17:34 +00:00Commented Jan 6, 2017 at 19:17