Go Down

Topic: PWM frequency library (Read 91786 times) previous topic - next topic


Hi thanks for a great library i find it works well on the uno. I am varying the frequency and pulse width by reading 2 pots on the analog inputs and mapping that reading to suit the registers for frequency and pulse width. I am using pin 9 and 10 and invert 10 also control its pulse width with another pot.  Great library.

Hi, a simple question. Can I have 4 outputs with high resolution on a Arduino UNO?
Excellent library runnerup. Thank you!

Anyone know why pin 11 on timer2 doesn't work?

All the rest work great.

I'm using the Uno.



hallo !
i'm using the arduno uno r3
if iwant to run the sevro motor (hg-kr053) and driver is Mitsubishi mr-j4-10a
how do i run this motor by arduino ?
      _________   __20K Hz
     /              \
    /                \
   /                  \
  /                    \
 rising time 0.2s and run 1s (20K Hz) down time 0.2s
and reten is the same.

i need the code!

Nov 25, 2014, 09:26 am Last Edit: Nov 25, 2014, 09:27 am by ross4435897

I used PWM library to generate PWM signals of desired frequency. The problem is i am not able to give a phase shift to the PWM. For example i am generating a PWM of frequency of 25Khz on PIN 9 and i need a phase shift of 90 degrees(i.e a phase shift of 40 microseconds) of the same PWM on PIN10. 'delay' command is not working. Please suggest a solution and thank you.   


Thanks for this library!


Thank you runnerup for this nice piece of work!

I have some questions for you, since I really need to expand this library for the Micro/Leonardo.
So that is what I will do, but maybe you can help me in the right direction.

  • In your estimation, can I better build of of ATimerDefs or BTimerDefs?
  • Do you have any idea how I could implement the difference in structure of the new 8 - 10 - 16 bit pins and fast PWM?
  • I want to change some of the timer--pin assignments for my project. Is that something that you think will work correctly with the construction you used for the library?
  • I will find my way in the end, but can you give me some places to start looking for the registers and stuff?

Any hint is welcome.

Many thanks in advance!
Christophe aka Petit Jean
Any luck with Arduino Leonardo?
Thank you


Please don't crosspost.  I see this same request in Project Guidance. Duplicate is being deleted.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.


Anyone have any ideas how to get this library to work with the 1.6.0 version of the IDE? I am having trouble getting it to recognize the library if it is in the "libraries" directory. I tried moving the files to a src directory but that did not help.

I finally gave up and put the files into the same directory as my sketch. That way I can get it to compile, but the output pin no longer has any output.

For reference, this sketch worked in the older version if the IDE. The sketch only stopped working when I upgrade to 1.6.0.


i think is the new library system, it need to be updated
sei nuovo? non sai da dove partire? leggi qui: http://playground.arduino.cc/Italiano/Newbie

I want six pins pwm output.
I use your library.
The pin6 and pin11 always duty=100%.
Why they didn`t work correctly like other pin?
Here is my code,please give me an answer,thanks.

#include <PWM.h>
void setup()



void loop()
   int x=32768;
   Serial.println("High Resolution PWM");

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131