Arduino mega PWM output pins

I have a project I want to build and I need 24 pwm outputs. I will be using a arduino mega and it says 14 of the digital pins can be used as pwm outputs. Can I just pick them or are there specific ones I should use.

Can I just pick them or are there specific ones I should use.

If you pick from the PWM pins, yes, you can pick them. The PWM pins are 2 through 13.

I will be using a arduino mega and it says 14 of the digital pins can be used as pwm outputs. Which ones?

Which ones?

Well, the web site says 15, but I only see 12 labeled as PWM pins. You can look at the source code to see how many there really are.

In any case, 12, 14 and 15 are all less than 24. So, does it really matter whether it is 12, 14, or 15?

The arduino reference for analogWrite states:

On most Arduino boards (those with the ATmega168 or ATmega328), this function works on pins 3, 5, 6, 9, 10, and 11. On the Arduino Mega, it works on pins 2 through 13. Older Arduino boards with an ATmega8 only support analogWrite() on pins 9, 10, and 11.

That’s 12, correct?

Lefty

http://arduino.cc/en/Main/ArduinoBoardMega2560

PWM: 2 to 13 and 44 to 46. Provide 8-bit PWM output with the analogWrite() function.

LOL, 12,14,15. Lots of discrepancies in the arduino mega2560 product and analogWrite() reference sections on this.

Lefty

retrolefty:
Lots of discrepancies in the arduino mega2560 product and analogWrite() reference sections on this.

That’s when you go to the source. From the mega’s pins_arduino.h definition:
#define digitalPinHasPWM(p) (((p) >= 2 && (p) <= 13) || ((p) >= 44 && (p)<= 46))