'SetPinFrequencySafe' cannot be used as a function Error compiling.

I have read through Runnerup’s posts, and cannot find a solution to this problem. I copied the code, and have checked and rechecked it, but cannot see any error in the code, or its syntax.

It may be something basic and obvious, but I can’t see it, for the life of me.

I would greatly appreciate a pointer. I’m using Arduino 1.6.1. Could this be the problem?


#include <PWM.h>
int32_t frequency =30000; //frequency in Hz

void setup()
  bool success = SetPinFrequencySafe(9, frequency);
  if(success) {
    pinMode(13, OUTPUT);
    digitalWrite(13, HIGH);

void loop()
  int sensorValue = analogRead(A0);
  pwmWrite(9, sensorValue / 4);

HI, What model arduino are you compiling it for?

Tom... :)

Sorry! it's an arduino nano r3 clone

Hi, I tried to compile it as UNO, needed to have PWM library.


Place the PWM folder into the MyDocument/Arduino/Libraries folder Then reboot the IDE.

Tom.... :)

Well, I've successfully used it before with the same setup, but I will remove it all and try again. I've now done this, and now have different errors. I think it's to do with file locations - what do you think?

/Users/mihaisofti/Documents/Arduino/libraries/ArduinoPWMLibv_05/PWM.h:36:33: fatal error: utility/BTimerDefs.h: No such file or directory

include "utility/BTimerDefs.h"

Thanks for the suggestions though.


The folder containing the offending files were nested inside another folder, so I moved the nested folder up one level, and all is now well. Thanks for your help Tom