Iscalef()は実数入力値を指定した実数範囲に変換します。
float Iscalef(float x, float in_min, float in_max, float out_min, float out_max)
| コマンド | 引数 | 戻り値 | 動作 |
|---|---|---|---|
Iscalef(x, in_min, in_max, out_min, out_max) | float x — 変換する入力値float in_minfloat in_maxfloat out_minfloat out_max | float | 実数入力値を指定した実数範囲に変換します。 |
void setup() { Serial.begin(115200); } void loop() { const float raw = (float)analogRead(A0); // 指定チャンネルの生のアナログ値を読み取ります。 const float pressureBar = Iscalef(raw, 0.0F, 32767.0F, 0.0F, 10.0F); // 浮動小数点入力値を指定した浮動小数点範囲に変換します。 if (pressureBar >= 0.0F && pressureBar <= 10.0F) Serial.println(pressureBar, 2); delay(100); }
Iscale()のすべての引数と戻り値の範囲は-2147483648~2147483647です。