analogWriteInit() sets the resolution and prescaler of the output timer.
void analogWriteInit(uint8_t ch, uint16_t top = 65535, uint16_t prescaler = 1)
| Command | Arguments | Return Value | Operation |
|---|---|---|---|
analogWriteInit(ch, top, prescaler) | uint8_t chuint16_t top = 65535uint16_t prescaler = 1 | void | Sets the resolution and prescaler of the output timer. |
void setup() { analogWriteInit(0, 65535, 1); // Set the output timer's resolution and prescaler. analogWrite(0, 32767); // Approx. 50% analogWrite(1, 65535); // 100% } void loop() { }
analogWrite(0~15, value) is for Y analog output, and analogWrite(20~31, value) is for K/K2 high-speed pulse output.D130~D135 and K2 D130~D141, fixed regardless of the number of Y modules.0~65535 values; high-speed pulse output uses Arduino-compatible 0~255 values.analogWriteInit(), analogWriteFreq() and analogWriteMax() are for Y analog output channels. Do not use them for high-speed pulses 20~31.analogWrite(130~141, value).analogWriteFreq() automatically changes TOP, so it also changes the maximum duty value for subsequent analogWrite() calls.analogWriteFreq() or analogWriteMax() to check the current maximum duty value.