0

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.

Mark Smith
2,1811 gold badge11 silver badges14 bronze badges
asked Jan 6, 2017 at 17:51

1 Answer 1

3

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.

answered Jan 6, 2017 at 18:37
2
  • .Thanku so much. now i understood. your exampple of ruler just nailed it. Commented Jan 6, 2017 at 19:12
  • You're welcome. If the answer was helpful you can accept it and optionally up-vote it :-) Commented Jan 6, 2017 at 19:17

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.