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

Next revision
Previous revision
en-us_commands:reference:analogread [2026/09/07 21:52] – 만듦 - 바깥 편집 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); +  const int first = analogRead(0);  // Read the raw analog value from X1 CH0. 
-  int ai4 = analogRead(4); +  const int second = analogRead(4);  // Read the raw analog value from X2 CH0. 
-  int32_t avg0 = analogReadAvg(0, 5); +  Serial.print(F("X1 CH0: ")); 
-  float avg0f = analogReadAvgf(0, 5); +  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);
 } }
Line 50: Line 41:
   * Using both averaging functions allocates separate dynamic buffers and increases SRAM usage.   * Using both averaging functions allocates separate dynamic buffers and increases SRAM usage.
   * The MPAINO analog input module's DIP switches and actual wiring must match the input type.   * The MPAINO analog input module's DIP switches and actual wiring must match the input type.
 +
 +===== Built-in Commands in the Same Category =====
 +
 +  * [[:en-us_commands:reference:analogreadinit|analogReadInit() View detailed description]]
 +  * [[:en-us_commands:reference:analogreadavg|analogReadAvg() View detailed description]]
 +  * [[:en-us_commands:reference:analogreadavgf|analogReadAvgf() View detailed description]]
  
 [[:en-us_commands:builtin|← Built-in Command List]] [[:en-us_commands:builtin|← Built-in Command List]]
  
en-us_commands/reference/analogread.1788785565.txt.gz · Last modified: by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki