Table of Contents

analogWrite2()

analogWrite2() outputs a raw value for 4~20mA conversion on the specified channel.

analogWrite2 command operation flow

void analogWrite2(uint8_t ch, uint16_t value)

Commands

Command Arguments Return Value Operation
analogWrite2(ch, value) uint8_t ch
uint16_t value
void Outputs a raw value for 4~20mA conversion on the specified channel.

Example

void setup() {
  Serial.begin(115200);
  IanalogWriteInit(0, 1000, 0, false);  // Set the maximum, minimum and mode of MPAINO analog outputs.
}
 
void loop() {
  const int32_t demand = IanalogRead(0, 0, 1000);  // Map the analog input value to the specified integer range.
  IanalogWrite(0, 0, 1000, demand);  // Map the user's integer value to the analog output range and output it.
  analogWrite2(1, constrain(demand, 0, 1000));  // Output a raw value for 4–20mA conversion on the specified channel.
  delay(20);
}

Precautions

Built-in Commands in the Same Category

← Built-in Command List