how to set pwm frequency on arduino code example
Example: arduino custom pwm
int DUTY = 50; // Duty percentage
const int PWM_PIN = 8;
void setup()
{
pinMode(PWM_PIN, OUTPUT);
noInterrupts();
// Don't use loop() to avoid serialEventRun overhead
while (true) {
digitalWrite(PWM_PIN, HIGH);
delayMicroseconds(DUTY); // Duty set above
digitalWrite(PWM_PIN, LOW);
delayMicroseconds(100 - DUTY); // Calculates downtime
}
}
void loop(){}