====== IanalogWritef() ====== ''IanalogWritef()'' converts a user floating-point value to the analog output range and outputs it. {{:en-us_commands:reference:ianalogwritef.svg?900|IanalogWritef command operation flow}} ''void IanalogWritef(uint8_t ch, float min, float max, float value)'' ===== Commands ===== ^ Command ^ Arguments ^ Return Value ^ Operation ^ | ''IanalogWritef(ch, min, max, value)'' | ''uint8_t ch'' — Analog output pin or channel to write\\ ''float min'' — Minimum of the user input range\\ ''float max'' — Maximum of the user input range\\ ''float value'' — User input value to output | ''void'' | Converts a user floating-point value to the analog output range and outputs it. | ===== Example ===== const uint8_t DEMAND_INPUT = A0; const uint8_t OUTPUT_CHANNEL = 0; void setup() { Serial.begin(115200); } void loop() { const float demandVolts = IanalogReadf(DEMAND_INPUT, 0.0F, 10.0F); // Map the analog input value to the specified floating-point range. IanalogWritef(OUTPUT_CHANNEL, 0.0F, 10.0F, demandVolts); // Map the user's floating-point value to the analog output range and output it. Serial.print(F("demand=")); Serial.print(demandVolts, 2); Serial.println(F("V")); delay(250); } ===== 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 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:ianalogwriteinit|IanalogWriteInit() View detailed description]] * [[:en-us_commands:reference:ianalogwrite|IanalogWrite() View detailed description]] [[:en-us_commands:builtin|← Built-in Command List]]