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이다.