Pwm

Hi all i want to fixe a frequency to 20 khz with my arduino uno and make variety the duty cycle by analog input like with potenciometer so i tried this code someone help me
#include <PWM.h>
int pin=3;
int potenciometer = 5;
void setup()
{
pinMode(3, OUTPUT);
pinMode(5,INPUT);
Serial.begin(9600);

InitTimersSafe();

//sets the frequency for the specified pin
bool success = SetPinFrequencySafe(pin, 20000); //success == true if it worked

}

void loop()
{
SetPinFrequencySafe(pin, 20000); //or you can set it in the loop at anytime

int value = analogRead(potenciometer);
int motor_speed = value/4;
analogWrite(pin,motor_speed);

Serial.println(motor_speed);

}

so i tried this code someone help me

What happened when you tried it ?