Unable to add PWM frequency Library successfully

Hello All,

I want to use the PWM frequency library. I have downloaded the zip file from Google Code Archive - Long-term storage for Google Code Project Hosting..

The library details can be found at PWM frequency library - Libraries - Arduino Forum

I followed the instructions to install the library (http://arduino.cc/en/Guide/Libraries)

however, when i am trying to verify the example present with the library file, below errors are encountered:

PWM_lib_example.ino: In function 'void setup()':
PWM_lib_example:24: error: 'InitTimersSafe' was not declared in this scope
PWM_lib_example:27: error: 'SetPinFrequencySafe' was not declared in this scope
PWM_lib_example.ino: In function 'void loop()':
PWM_lib_example:39: error: 'pwmWrite' was not declared in this scope

the sketch is :

#include <PWM.h>

//use pin 11 on the Mega instead, otherwise there is a frequency cap at 31 Hz
int led = 9; // the pin that the LED is attached to
int brightness = 0; // how bright the LED is
int fadeAmount = 5; // how many points to fade the LED by
int32_t frequency = 35; //frequency (in Hz)

void setup()
{
//initialize all timers except for 0, to save time keeping functions
InitTimersSafe();

//sets the frequency for the specified pin
bool success = SetPinFrequencySafe(led, frequency);

//if the pin frequency was set successfully, turn pin 13 on
if(success) {
pinMode(13, OUTPUT);
digitalWrite(13, HIGH);
}
}

void loop()
{
//use this functions instead of analogWrite on 'initialized' pins
pwmWrite(led, brightness);

brightness = brightness + fadeAmount;

if (brightness == 0 || brightness == 255) {
fadeAmount = -fadeAmount ;
}

delay(30);
}

I am just a beginner in the field. Request your expert guidance

regards
Rajdeep

Hello,

Weird, I've just tried to install this library and the example compiled successfully. Make sure you installed it correctly: extract the zip file in Documents/Arduino/libraries. Then I suggest that you move the examples inside the library's folder in a new folder "Examples", so that you have folder structure like this:

Documents/Arduino/libraries/PWM/keywords.txt
Documents/Arduino/libraries/PWM/PWM.h
Documents/Arduino/libraries/PWM/Examples/PWM_lib_example/PWM_lib_example.ino
Documents/Arduino/libraries/PWM/Examples/PWM_lib_resolution_example/PWM_lib_resolution_example.ino
Documents/Arduino/libraries/PWM/utility/ATimerDefs.cpp
Documents/Arduino/libraries/PWM/utility/ATimerDefs.h
Documents/Arduino/libraries/PWM/utility/BTimerDefs.cpp
Documents/Arduino/libraries/PWM/utility/BTimerDefs.h

Thank you !!!!!!!!!!!!!!!!!!

i am able to use PWM frequency library now.

regards
Rajdeep

For future reference, try and use [ code ] tags (without the spaces) around your code. It makes it a-lot nicer to look at and maintains proper formatting. =)

Sorry, could you help me. Even though I follow your above steps, it can't work with below errors. Please help me.

sketch\PWM_lib_example.ino.cpp.o: In function `setup':

C:\Program Files (x86)\Arduino\libraries\PWM\Examples\PWM_lib_example/PWM_lib_example.ino:24: undefined reference to `InitTimersSafe()'

C:\Program Files (x86)\Arduino\libraries\PWM\Examples\PWM_lib_example/PWM_lib_example.ino:27: undefined reference to `SetPinFrequencySafe(signed char, unsigned long)'

sketch\PWM_lib_example.ino.cpp.o: In function `loop':

C:\Program Files (x86)\Arduino\libraries\PWM\Examples\PWM_lib_example/PWM_lib_example.ino:39: undefined reference to `pwmWrite(unsigned char, unsigned char)'

collect2.exe: error: ld returned 1 exit status

exit status 1
Error compiling.

Thank you!