ユーザ用ツール

サイト用ツール


ja-jp_commands:reference:iscalef

Iscalef()

Iscalef()は実数入力値を指定した実数範囲に変換します。

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_min
float in_max
float out_min
float 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です。
  • 範囲外の入力は近い方の出力端点に制限されます。
  • 両コマンドは線形範囲変換だけを行い、センサ校正や電気的保護の代わりにはなりません。

同じカテゴリの内蔵コマンド

ja-jp_commands/reference/iscalef.txt · 最終更新: by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki