1

I'm newbie in arduino due. I need to reduce the default PWM frequency of arduino Due. Anyone have any tutorial to do this? (Frequencys like 25hz, 50Hz for example)

I read in some posts, if i change the PWM frequency, i make changes in internal timers of arduino and i loss functions like delay(), millis(), etc.

Exits any form to not lose these functions?

Thanks a lot!

asked Sep 11, 2017 at 20:12
1
  • 25 and 50 hz square wave can be generated by software easily Commented Sep 11, 2017 at 20:22

1 Answer 1

-1

The Palatis Softpwm library can generate PWM on any digital pin with (almost) any frequency. Example for 25Hz:

#include <SoftPWM.h>
SOFTPWM_DEFINE_CHANNEL(0, DDRB, PORTB, PORTB2); //Arduino pin 10
void setup() {
 // begin with 25Hz pwm frequency
 Palatis::SoftPWM.begin(25);
 Palatis::SoftPWM.set(0, value); // value is 0 to 255 just like normal Arduino analogWrite
}
answered Sep 11, 2017 at 21:09

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.