IanalogRead() converts the analog input value to the specified integer range.
int32_t IanalogRead(uint8_t ch, int32_t min, int32_t max)
| Command | Arguments | Return Value | Operation |
|---|---|---|---|
IanalogRead(ch, min, max) | uint8_t ch — Analog input pin or channel to readint32_t min — Minimum int32_t conversion resultint32_t max — Maximum int32_t conversion result | int32_t | Converts the analog input value to the specified integer range. |
void setup() { Serial.begin(115200); } void loop() { int32_t percent = IanalogRead(A0, 0, 100); // Map the analog input value to the specified integer range. Serial.println(percent); delay(500); }
min and max define the conversion range of the return value, not the actual electrical input range of the sensor.Iscale() or Iscalef() keeps the result between the two specified output endpoints.min greater than max reverses the output range. Example: IanalogRead(A0, 100, 0).ch appropriate to the selected board.