PWM frequency and duty cycle

Hello,

I need to control both frequency and duty cycle for multiple PWM channels.

Rignt now im using this code to control the duty cycle

pinMode(PWM_A, OUTPUT);
analogWrite(PWM_A,duty);

How can i control the frequency of the PWM as well as the duty cycle?

Thanks

Hi @nsmith1024,

You can use void analogWritePeriod(int us) to set the duty cycle. Do a loop for the analogWrite API for the frequency.

Thank you.