繁体   English   中英

map function 在 C 中实现

[英]map function implementation in C

how can i implement a map function in C so I can use it in atmel studio for example the map function arduino C how can I use it in Atmel Studio

x = analogRead(A0);
y = map (x, 0 , 1023 , 0 , 2500 );

来自 Arduino 参考: https://www.arduino.cc/reference/en/language/functions/math/map/

对于数学倾向,这里是整个 function

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;
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM