en-us_commands:reference:iscale
This is an old revision of the document!
Table of Contents
Iscale()
Iscale() converts an integer input value to the specified integer range.
int32_t Iscale(int32_t x, int32_t in_min, int32_t in_max, int32_t out_min, int32_t out_max)
Commands
| Command | Arguments | Return Value | Operation |
|---|---|---|---|
Iscale(x, in_min, in_max, out_min, out_max) | int32_t x — Input value to convertint32_t in_minint32_t in_maxint32_t out_minint32_t out_max | int32_t | Converts an integer input value to the specified integer range. |
Example
void loop() { int32_t raw = (int32_t)analogRead(A0); int32_t percent = Iscale(raw, 0, 1023, 0, 100); float voltage = Iscalef((float)raw, 0.0F, 1023.0F, 0.0F, 5.0F); Serial.println(percent); Serial.println(voltage, 2); }
Precautions
- All arguments and the return value of
Iscale()have a range of-2147483648~2147483647. - Out-of-range inputs are clamped to the nearest output endpoint.
- Both commands perform only linear range conversion. They do not replace sensor calibration or electrical protection.
en-us_commands/reference/iscale.1788785568.txt.gz · Last modified: by 127.0.0.1
