Table of Contents

analogWriteFreq()

analogWriteFreq() sets the PWM frequency of the specified output channel.

analogWriteFreq command operation flow

uint16_t analogWriteFreq(uint8_t ch, uint32_t frequencyHz)

Commands

Command Arguments Return Value Operation
analogWriteFreq(ch, frequencyHz) uint8_t ch
uint32_t frequencyHz
uint16_t Sets the PWM frequency of the specified output channel.

Example

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() {
}

Precautions

Built-in Commands in the Same Category

← Built-in Command List