Skip to main content
Arduino

Return to Question

added 29 characters in body
Source Link
gre_gor
  • 1.7k
  • 4
  • 18
  • 28

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
}
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?

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?

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?

Need help to set Set PWM frequency to 25kHz25 kHz

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

void setup()
{
 TCCR1B = TCCR1B & B11111000 | B00000001; // Set PWM frequency for D9 & D10:
 pinMode(pwmPin9, OUTPUT); // setsSets the pin as output
 pinMode(pwmPin10, OUTPUT); // setsSets the pin as output


 TCCR2B = TCCR2B & B11111000 | B00000001; // Set PWM for D3 & D11
 pinMode(pwmPin3, OUTPUT); // setsSets the pin as output
 pinMode(pwmPin11, OUTPUT); // setsSets the pin as output
}

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

Need help to set PWM frequency to 25kHz

I currently can set four pwm pins to around 31kHz 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 25kHz instead. How is that possible?

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?

Tweeted twitter.com/StackArduino/status/908413756937572352
Source Link
user16307
  • 237
  • 2
  • 4
  • 15

Need help to set PWM frequency to 25kHz

I currently can set four pwm pins to around 31kHz 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 25kHz instead. How is that possible?

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