analogWrite doesn't work on D1/A7 with DFArduino

I want to use analogWrite to enable the motors for the DFRobot. However, whenever I send an analogWrite request to either D1 or A7 (which are PWM?), the DFArduino board gives off a warning beep.

Example:

analogWrite(A7,20);
delay(500);
analogWrite(A7,LOW);

Is there something obvious I’m missing? I do get the motors to operate with a digitalWrite.
I receive the same reaction for both analog and digital writes using the Tinker app.

Hello @max I checked the PWM functionality on those pins with the shield-shield and a couple of LEDs. That seems to work. I don’t have the robot shield handy right now to test it on the actual robot.

You may have tried this out, but just to make sure:

  1. Did you confirm the jumper setting to be same as the one on the documentation?
  2. Did you try higher values (say 200 and above?)
  3. Could you provide the actual source code you are using? I’ll test it as soon as I have access to my robot.

Thanks!

Hi @mohit!

Performing an analogWrite with a higher value worked!
I was hesitant to try a higher value before since with lower settings, the motor didn’t run and there was a constant low beep coming from the Arduino board.

With higher values (50+) the motor did work and the beep became relatively more quiet (completely gone at 255).
Do you know why that might be?

@max The beep that you hear is the PWM signal (at 500Hz) running through the motors. Lower values aren’t enough to get the motors spinning as they have to come over the inertia. Once you get them going, you can reduce the speed. Most people use an acceleration profile to compensate for this behavior.

At high speeds, the motors themselves make enough noise to muffle the PWM noise.

Hope you are having fun with the Core and the robot!