Table of Contents

analogRead()

analogRead() reads the raw analog value of the specified channel.

analogRead command operation flow

int analogRead(uint8_t pin)

Commands

Command Arguments Return Value Operation
analogRead(pin) uint8_t pin — On MPAINO, 0 ~ 19 are overall analog input module channel numbers int Reads the raw analog value of the specified channel.

Example

This example uses MPAINO-8A8R(T) with two X input modules. Select Analog Input Module → X2 in Arduino IDE. CH0 on X1 is 0; CH0 on X2 is 4.

void setup() {
  Serial.begin(115200);
}
 
void loop() {
  const int first = analogRead(0);  // Read the raw analog value from X1 CH0.
  const int second = analogRead(4);  // Read the raw analog value from X2 CH0.
  Serial.print(F("X1 CH0: "));
  Serial.println(first);
  Serial.print(F("X2 CH0: "));
  Serial.println(second);
  delay(500);
}

Precautions

Built-in Commands in the Same Category

← Built-in Command List