Variable Frequency using Arduino

Hello All,

How can I get variable frequency PWM using Arduino?

Currently i follow link https://etechnophiles.com/change-frequency-pwm-pins-arduino-uno/
But I can generate fixed PWM frequency on a different pin. but that frequency does not match my requirement.

  1. Can anyone suggest to me how can I get variable frequency 1kz to 6khz using Arduino Uno or I need the different boards for this?

I would use Timer/Counter 1 for PWM on Pin 9 and/or Pin 10. If you use WGM 14 you can set the TOP of the PWM count to set the frequency.

johnwasser:
I would use Timer/Counter 1 for PWM on Pin 9 and/or Pin 10. If you use WGM 14 you can set the TOP of the PWM count to set the frequency.

Sir, How can I set the PWM count?
please guide me.

Somebody wrote a library to do what you want. This should be much easier than reading the datasheet and learning how to program the timers.

https://forum.arduino.cc/index.php?topic=117425.0

https://code.google.com/archive/p/arduino-pwm-frequency-library/downloads

The TimerOne library will also meet your needs for pins 9 and 10.