Using the Adafruit_Motor_Shield_V2_Library

To adjust the PWM frequency of the Motor Shield or Motor FeatherWing, refer to the Arduino code example for the Adafruit_Motor_Shield_V2_Library: 

DC Motor Test Example

Using this library, the frequency can be changed from the default 1600Hz by including the new value in the begin statement:

AFMS.begin(100); // Set the PWM frequency to 100Hz

Note that, at this time, the library does not provide a parameter for changing the default controller decay mode from FAST_DECAY to SLOW_DECAY.

Using the analogWrite() Function

The PWM frequency of microcontroller GPIO pins using the analogWrite() function is fixed and cannot be changed. PWM signals sent directly to a motor controller breakout from GPIO pins will default to a frequency of 490Hz to 1000Hz depending on the microcontroller board used. See Arduino Reference: analogWrite() for more information.

This guide was first published on Feb 23, 2021. It was last updated on 2021-02-23 15:22:04 -0500.

This page (Arduino Code Example) was last updated on Apr 04, 2021.

Text editor powered by tinymce.