Page 1 of 1

Pwm set frequency and duty cycle in Arduino or similar board.

Posted: Wed Feb 03, 2021 8:04 pm
by solozerouno
How can I create a PWM with variable frequency from 1hz to 200hz for example and within each cycle have a duty cycle from 1 to 99%? There is a similar card on Amazon that once the pwm is set in hz or khz also makes the pwm adjust from 1 to 99%. Can it be done with an Arduino uno or Mega 256 or an Esp 32 wroom? If so, can you give me an example in flowcode 9 or a video on YouTube? Thanks a lot Alessandro.

Re: Pwm set frequency and duty cycle in Arduino or similar board.

Posted: Fri Feb 05, 2021 12:38 pm
by BenR
Hello,

I don't think the PWM on the Arduino can be made to run as slow as 1Hz and you might find that it's difficult to get that sort of range using hardware PWM.

Have you considered using software PWM using a timer interrupt? That might be a bit more flexible and provide more options.

There is an example of software PWM here but please let us know what you think and how you're getting on if you give this a go.
https://www.flowcode.co.uk/wiki/index.p ... ftware_PWM