User Tools

Site Tools


en-us_commands:reference:analogread

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
en-us_commands:reference:analogread [2026/09/08 00:53] – 바깥 편집 127.0.0.1en-us_commands:reference:analogread [2026/09/14 20:30] (current) – external edit 127.0.0.1
Line 14: Line 14:
  
 ===== Example ===== ===== 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''.
  
 <code cpp> <code cpp>
Line 21: Line 23:
  
 void loop() { void loop() {
-  int ai0 = analogRead(0);  // Read the raw analog value of the specified channel+  const int first = analogRead(0);  // Read the raw analog value from X1 CH0
-  int ai4 = analogRead(4);  // Read the raw analog value of the specified channel. +  const int second = analogRead(4);  // Read the raw analog value from X2 CH0
-  int32_t avg0 = analogReadAvg(0, 5);  // Return the integer average of multiple input values. +  Serial.print(F("X1 CH0: ")); 
-  float avg0f = analogReadAvgf(0, 5);  // Return the floating-point average of multiple input values. +  Serial.println(first); 
- +  Serial.print(F("X2 CH0: ")); 
-  Serial.print("AI0: "); +  Serial.println(second);
-  Serial.println(ai0); +
- +
-  Serial.print("AI4: "); +
-  Serial.println(ai4); +
- +
-  Serial.print("AI0 AVG: ")+
-  Serial.println(avg0); +
- +
-  Serial.print("AI0 AVG float: "); +
-  Serial.println(avg0f, 2); +
   delay(500);   delay(500);
 } }
en-us_commands/reference/analogread.1788796394.txt.gz · Last modified: by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki