Go Down

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


This Library didn't work. The following message was appeared:
The library "Arduino PWM Frequency Library v_05" cannot be used.
Library names must contain only basic letters and numbers.
(ASCII only and no spaces, and it cannot start with a number)

Please, I need it!


Hi, could anyone help me?
I have noticed that there's no PWM.cpp file. The library wasn't installed.


You extracted the filename of the zip file directly into your library directory as "Arduino PWM Frequency Library v_05"
You should simply make a directory under libraries and call it PWM for example.
C:\Program Files\arduino-1.8.1\libraries\PWM

Then copy all the stuff in under the PWM directory into this new library PWM directory, and copy PWM_lib_example and PWM_lib_resolution_example into there as well.

It should look like this when your done ...

 Directory of C:\Program Files\arduino-1.8.1\libraries\PWM

11-May-2018  16:49    <DIR>          .
11-May-2018  16:49    <DIR>          ..
16-Aug-2012  16:55             2,208 keywords.txt
24-Sep-2012  15:24             4,873 PWM.h
11-May-2018  14:38    <DIR>          PWM_lib_example
11-May-2018  14:38    <DIR>          PWM_lib_resolution_example
11-May-2018  16:49                 0 showDir.txt
11-May-2018  14:38    <DIR>          utility
               3 File(s)          7,081 bytes
               5 Dir(s)  113,831,374,848 bytes free


I like to using this pwm.h librari variable phase shifting arduino between two pwm chanel.
I like the shifing variable 0-180 degrees.

Somebody doing same?



Cannot compile the code for Atmega8. While I tried compiling for Atmega168, the code uses 2720 bytes of space and compiles successfully and works fine. Anyone please help me.


post your code if you want help



I am trying to lower the Arduino Uno PWM frequencies to drive 4 x solenoid valves. Ideally, pins 5 & 6 are untouched to retain timer0 function. However, understand that creating custom frequencies would sacrifice 2 pins on Arduino, which I have found out to be pins 6 and 11. 

In the original post by runnerup:
"If you don't want to sacrifice any 8bit PWM pins, don't call the initialize function for that timer, try changing the prescaler to manipulate frequency instead. "

So if I would like to leave pins 5 and 6 untouched and change PWM frequency for pins 3, 9, 10 AND 11 to 31Hz? Do I simply use this setup to change the timer prescaler and the PWM frequencies for the 4 pins would be lowered to 31Hz?

Code: [Select]
void setup()

I tried doing that and alternatively using this function PwmFrequency to also change the prescaler. But neither works.

So is this a limitation such pins 6 and 11 cannot be used?

Appreciate some clarification/ advice, thanks!


Great Library

Some problems i am facing:
1- Cannot modify the frequency of pin 11, the bool doesn't return success
2- Can't get the resolution on pin 3 and 11 although the timer gives me resolution


The Leonardo has a different CPU architecture. That means different timers with different properties that I would have to wrap.
So far, Arduino microcontrollers use three main architectures 'groups'.  Arduino Mega and ADK are of the AVR mega 1280/1281/2560/2561 group, which are all identical except for the amount of memory they hold. The Leonardo uses ATmega32u4. And pretty much everything else uses 88/168/328 variants.
I have an Uno and a Mega, which means I was able to build and test for every architecture except the Leonardo. If there is enough interest in this project, I would be willing to try to get it working on the Leonardo. But I have no reliable way too test it in real life to make sure it works.
I am using Atmega 64/128/256 with MegaCore , your library is very necessary for me for one project. But it does not support this processor. Can you help me? Thanks.


I've tried implementing the library and i get an error, i thought this was supposed to work for all Arduinos?



Not ALL libraries are meant for ALL Arduinos.
Which Library the one in question already or a different one ?

What board are you trying to use your lib with ?

Ok less questions and more directions.
Please read the sticky posts at the top of forum sections and add the details they recommend.

It may not be the answer you were looking for but its the one I am giving based on either experience, educated guess, google or the fact that you gave nothing to go with in the first place so I used my wonky crystal ball.

Go Up