[英]What is the syntax used for the library that contains the built-in map function on Arduino?
我一直在瀏覽各個站點,但似乎找不到關於 Arduino function 庫的信息的太多信息。 我正在使用 HCS12 微控制器 (MC9S12DG256B),它在引導加載程序中內置了更少的庫。 這些缺少的功能之一包括內置 map function。 我特別詢問 Arduino 在包含 map function 的庫中使用的數學和語法。 Arduino 如何定義 map function? 這是我試圖在用 Arduino 語法編寫的微型計算機上定義的內容。
int pot;
int PWM = map(pot,0,1023,3300,5700);
從文檔
https://www.arduino.cc/reference/en/language/functions/math/map/
map(value, fromLow, fromHigh, toLow, toHigh)
值:編號為 map。
fromLow:值的當前范圍的下限。
fromHigh:值的當前范圍的上限。
toLow:值的目標范圍的下限。
toHigh:值的目標范圍的上限。
數學 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.