User Tools

Site Tools


en-us_commands:reference:ianalogwrite

This is an old revision of the document!


IanalogWrite()

IanalogWrite() converts a user integer value to the analog output range and outputs it.

IanalogWrite command operation flow

void IanalogWrite(uint8_t ch, int32_t min, int32_t max, int32_t value)

Commands

Command Arguments Return Value Operation
IanalogWrite(ch, min, max, value) uint8_t ch — Analog output pin or channel to write
int32_t min — Minimum of the user input range
int32_t max — Maximum of the user input range
int32_t value — User input value to output
void Converts a user integer value to the analog output range and outputs it.

Example

void setup() {
}
 
void loop() {
  IanalogWrite(0, 0, 100, 50);  // 50% output
  delay(500);
}

Precautions

  • The argument order must be ch, min, max, value.
  • min and max define the user input range for interpreting value, rather than directly setting the electrical output range.
  • If value is outside min~max, the internal Iscalef() clamps it to the nearest endpoint.
  • Setting min greater than max reverses the output direction.
  • If min equals max, the output value is 0.
  • Changing Timer TOP with analogWriteInit() or analogWriteFreq() also changes the actual analogWrite() output range. Use the default TOP 65535 to retain 16-bit 0~65535 resolution.
  • Match the output module DIP switches, external supply and wiring to the connected equipment's input specifications.
  • Do not use these together with PWM, pulse output or counter commands using the same timer.

← Built-in Command List

en-us_commands/reference/ianalogwrite.1788785566.txt.gz · Last modified: by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki