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!

askedSep 11, 2017 at 20:12
FelipeFonsecabh's user avatar
1
  • 25 and 50 hz square wave can be generated by software easilyCommentedSep 11, 2017 at 20:22

1 Answer1

-1

ThePalatis 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 10void 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}
answeredSep 11, 2017 at 21:09
Mikael Falkvidd's user avatar

Your Answer

Sign up orlog in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

By clicking “Post Your Answer”, you agree to ourterms of service and acknowledge you have read ourprivacy 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.