Skip to main content
Arduino

Return to Revisions

2 of 3
Copy edited.

Set PWM frequency to 25 kHz

I currently can set four PWM pins to around 31 kHz with the following code:

void setup()
{
 TCCR1B = TCCR1B & B11111000 | B00000001; // Set PWM frequency for D9 & D10:
 pinMode(pwmPin9, OUTPUT); // Sets the pin as output
 pinMode(pwmPin10, OUTPUT); // Sets the pin as output
 TCCR2B = TCCR2B & B11111000 | B00000001; // Set PWM for D3 & D11
 pinMode(pwmPin3, OUTPUT); // Sets the pin as output
 pinMode(pwmPin11, OUTPUT); // Sets the pin as output
}

I found this setup somewhere, but I don't know how I can set these four PWM pins to around 25 kHz instead. How is that possible?

user16307
  • 237
  • 2
  • 4
  • 15

AltStyle によって変換されたページ (->オリジナル) /