This is an exotic procedure! The standard PWM frequency on the Arduino is around 490 Hz. While it can get most jobs done, it is not really that fast. However, we can change that.
Faster PWM is especially useful when controlling motors. At low PWM, the torque is greatly affected, and it can also create audible noise. The best way to test this is to implement the Controlling speed with PWM recipe from Chapter 5, Motor Control, and increase the PWM frequency.
A note to remember: this might interfere with other functions, such as
delay(). We have to be extra careful when this happens.
Following are the ingredients required to implement this recipe: