Skip to content

Added ATMega4809 compatibility to kiwisincebirth's PWM Frecuency library

Notifications You must be signed in to change notification settings

arufl/PWMFrequency

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

PWM Frequency Arduino Library

Library for Setting the PWM Frequency

Originaly written by kiwisincebirth 2014 https://github.com/kiwisincebirth/Arduino/tree/master/libraries/PWMFrequency

Please keep in mind that changing the PWM frequency changes the Atmega's timers and disrupts the normal operation of many functions that rely on time (delay(), millis(), Servo library).

This Library supports ATMega 328, 32U4 (Leonardo) and ATMega4809 (Nano Every).

Example

Here are some usage examples of the function:

// Set pin 9's PWM frequency to 3906 Hz (31250/8 = 3906) // Note that the base frequency for pins 3, 9, 10, and 11 is 31250 Hz setPwmFrequency(9, 8);

// Set pin 6's PWM frequency to 62500 Hz (62500/1 = 62500) // Note that the base frequency for pins 5 and 6 is 62500 Hz setPwmFrequency(6, 1);

// Set pin 10's PWM frequency to 31 Hz (31250/1024 = 31) setPwmFrequency(10, 1024);

See

http://playground.arduino.cc/Code/PwmFrequency

Thanks to macegr of the Arduino forums for his documentation of the PWM frequency divisors. His post can be viewed at: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1235060559/0#4

Thanks to MacTester57 (aka TheDIYGuy999) for providing ATMega 32U4 testing http://www.tonymacx86.com/imac-mods/107859-kiwis-next-project-imac-g5-10.html#post765116

Thanks to plymdiver of the Arduino forums for his explaination on how the ATmega4809 timers works and which timer corresponds each pin. https://forum.arduino.cc/index.php?topic=626736.msg4503396#msg4503396

Version History

2.0 2014-07-30 Added Support for ATMega 32U4 Leonardo timers

Because it looks like, that this repo (https://github.com/kiwisincebirth/Arduino/tree/master/libraries/PWMFrequency) is not maintained anymore, I've cloned it.

The following changes were done by me, TheDIYGuy999:

2.1:

  • Syntax coloration enhanced
  • folder structure changed, so you can download and install it as usual

Changes done by arufl:

2.2

  • Support for Nano Every

About

Added ATMega4809 compatibility to kiwisincebirth's PWM Frecuency library

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 100.0%