analogReadInit() sets the sampling rate of the analog input module.
void analogReadInit(uint16_t sps)
| Command | Arguments | Return Value | Operation |
|---|---|---|---|
analogReadInit(sps) | uint16_t sps | void | Sets the sampling rate of the analog input module. |
void setup() { Serial.begin(115200); // Use autocomplete constants analogReadInit(IANALOG_SPS_250); // Set the analog input module's sampling rate. } void loop() { for (uint8_t ch = 0; ch < 4; ch++) { Serial.print("CH"); Serial.print(ch); Serial.print(" = "); Serial.println(analogRead(ch)); // Read the raw analog value of the specified channel. } }
analogReadInit(128) uses the nearest higher RATE of 250 SPS, rather than 256 SPS, which the ADS1118 does not provide.analogRead() converts the same channel twice to prevent channel-value displacement. Include both conversion times when calculating the total channel update time.