analogWriteFreq() sets the PWM frequency of the specified output channel.
uint16_t analogWriteFreq(uint8_t ch, uint32_t frequencyHz)
| Command | Arguments | Return Value | Operation |
|---|---|---|---|
analogWriteFreq(ch, frequencyHz) | uint8_t chuint32_t frequencyHz | uint16_t | Sets the PWM frequency of the specified output channel. |
void setup() { analogWriteFreq(3, 1000); // Set the PWM frequency of the specified output channel. uint16_t maxValue = analogWriteMax(3); // Return the maximum value available for the specified output channel. analogWrite(3, maxValue / 4); // D46 / OC5A, approx. 25% analogWrite(4, maxValue / 2); // D45 / OC5B, approx. 50% analogWrite(5, maxValue); // D44 / OC5C, 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.