User Tools

Site Tools


en-us_commands:reference:ianalogwriteinit

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
en-us_commands:reference:ianalogwriteinit [2026/09/07 23:35] – 바깥 편집 127.0.0.1en-us_commands:reference:ianalogwriteinit [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 a Y output module and **Analog Output Module → Y** selected. It sets CH0 to a 0–1000 range and outputs its midpoint.
  
 <code cpp> <code cpp>
 void setup() { void setup() {
-  Serial.begin(115200); +  IanalogWriteInit(0, 1000, 0, false);  // Set Y module CH0 to a 0–1000 range.
-  IanalogWriteInit(0, 1000, 0, false);  // Set the maximum, minimum and mode of MPAINO analog outputs.+
 } }
  
 void loop() { void loop() {
-  const int32_t demand = IanalogRead(0, 0, 1000);  // Map the analog input value to the specified integer range. +  IanalogWrite(0, 0, 1000, 500);  // Output the midpoint of the configured range. 
-  IanalogWrite(0, 0, 1000, demand);  // Map the user's integer value to the analog output range and output it. +  delay(500);
-  analogWrite2(1, constrain(demand, 0, 1000));  // Output a raw value for 4–20mA conversion on the specified channel+
-  delay(20);+
 } }
 </code> </code>
Line 37: Line 36:
   * ''analogWriteInit()'', ''analogWriteFreq()'' and ''analogWriteMax()'' are for Y analog output channels and must not be used for high-speed pulse channels ''20~31''.   * ''analogWriteInit()'', ''analogWriteFreq()'' and ''analogWriteMax()'' are for Y analog output channels and must not be used for high-speed pulse channels ''20~31''.
   * Do not use high-speed pulse GPIO numbers ''130~141'' with ''analogWrite()''.   * Do not use high-speed pulse GPIO numbers ''130~141'' with ''analogWrite()''.
 +
 +===== Built-in Commands in the Same Category =====
 +
 +  * [[:en-us_commands:reference:analogwriteinit|analogWriteInit() View detailed description]]
 +  * [[:en-us_commands:reference:analogwritefreq|analogWriteFreq() View detailed description]]
 +  * [[:en-us_commands:reference:analogwritemax|analogWriteMax() View detailed description]]
 +  * [[:en-us_commands:reference:ianalogwrite|IanalogWrite() View detailed description]]
 +  * [[:en-us_commands:reference:ianalogwritef|IanalogWritef() View detailed description]]
  
 [[:en-us_commands:builtin|← Built-in Command List]] [[:en-us_commands:builtin|← Built-in Command List]]
  
en-us_commands/reference/ianalogwriteinit.1788791733.txt.gz · Last modified: by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki