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.

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.

  • .Thanku so much. now i understood. your exampple of ruler just nailed it. – user3605647 Jan 6 '17 at 19:12
  • You're welcome. If the answer was helpful you can accept it and optionally up-vote it :-) – Mark Smith Jan 6 '17 at 19:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.