0

I have been looking across various sites and I cannot seem to find much information regarding the information on the Arduino function libraries. I am using an HCS12 microcontroller (MC9S12DG256B) that has fewer libraries built into the bootloader. One of these lacking functionalities includes a built-in map function. I am specifically asking about the math and syntax that the Arduino utilizes in the library that contains the map function. How does Arduino define the map function? Here is what I am trying to define on my micro written in Arduino syntax.

int pot;    
int PWM = map(pot,0,1023,3300,5700);
Ryan Paye
  • 3
  • 2
  • There is an answer and really good explanation [here](https://stackoverflow.com/a/5732390/4902099) – hcheung Aug 21 '22 at 05:20

1 Answers1

0

From the docs

https://www.arduino.cc/reference/en/language/functions/math/map/

map(value, fromLow, fromHigh, toLow, toHigh)

value: the number to map.
fromLow: the lower bound of the value’s current range.
fromHigh: the upper bound of the value’s current range.
toLow: the lower bound of the value’s target range.
toHigh: the upper bound of the value’s target range.

The math function is also given

long map(long x, long in_min, long in_max, long out_min, long out_max) {
  return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}
ti7
  • 16,375
  • 6
  • 40
  • 68