You can set the Arduino's PWM frequency with great accuracy by using this library.
Links:
http://forum.arduino.cc/index.php?topic=117425.0
https://code.google.com/p/arduino-pwm-frequency-library/

By Julian

Youtuber, shed dweller, solar charge controller aficionado

14 thoughts on “Arduino pwm tutorial #2 – how to set pwm frequency accurately”
  1. Avataaar/Circle Created with python_avatars Amanda Nepo says:

    Hey! I'm having trouble downloading the PWM library to my arduino IDE. I know this video was made a while ago so I'm wondering if this library still works? I'm able to download the library to my computer but when I try the add .zip library it says "archive is not valid: multiple file found in zip file top level" also do you knwo if this library works for the ATtiny85? thanks

  2. Avataaar/Circle Created with python_avatars Little Clem says:

    Thank you i was just working with pwm. I was curious about changing freq. Thanks.

  3. Avataaar/Circle Created with python_avatars SSC Channel says:

    hello sir, why is this program not working on ATtiny85 ic?

  4. Avataaar/Circle Created with python_avatars Kartitronics Lab Pro says:

    Great informative content!

  5. Avataaar/Circle Created with python_avatars Tilotama Kodam says:

    Can we have a frequency of 225khz using this library

  6. Avataaar/Circle Created with python_avatars Josh Luis says:

    You just literally saved my life thank you!

  7. Avataaar/Circle Created with python_avatars sean123456789 says:

    Has anyone found a way to make this library work on the ATtiny? Or found a similar library that does work?

  8. Avataaar/Circle Created with python_avatars Jan Brož says:

    Can it handle 25khz?

  9. Avataaar/Circle Created with python_avatars Kaynaat Games says:

    There is a problem with this library, I had an inverter project where I needed to switch between mosfets at 10 milliseconds to get 50 hz acv output. The millis function works fine until 20 hz, no matter how hard I tried I couldn't switch between mosfets faster than 20 hz. So any timing above 20 milliseconds with the millis function works but not faster.

  10. Avataaar/Circle Created with python_avatars Scott in Florida says:

    Hello Julian, I am an old guy new to Arduino. I used your code for this generator. I need to output 369,000Hz. I can get 363k or 380k but not 369k. I wonder if I were to add a line of code to scan between 363k and 380k would it hit 369k. Can you help?

  11. Avataaar/Circle Created with python_avatars Gleiver Pérez says:

    To. The. Point. You're the dude, bravo!

  12. Avataaar/Circle Created with python_avatars Alphonse Synrem says:

    Thank you for detailed instructions. Very helpful.

  13. Avataaar/Circle Created with python_avatars Caleb Ngwa says:

    hello, i want to get a variable voltage output using PWM without using POT . What should i do.

  14. Avataaar/Circle Created with python_avatars Wasim Pysadee says:

    Have you published your codes?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.