사용자 도구

사이트 도구


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이다.
  • 범위를 벗어난 입력은 가까운 출력 끝값으로 제한된다.
  • 두 명령어는 선형 범위 변환만 수행하며 센서 보정이나 전기적 보호를 대신하지 않는다.

같은 카테고리의 내장 명령어

commands/reference/iscalef.txt · 마지막으로 수정됨: 저자 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki