Go Down

Topic: Arduino mega PWM output pins (Read 675 times) previous topic - next topic

jdmaag

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.

PaulS

Quote
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.

jdmaag

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

PaulS

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

retrolefty

The arduino reference for analogWrite states:

Quote
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

James C4S


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

PWM: 2 to 13 and 44 to 46. Provide 8-bit PWM output with the analogWrite() function.
Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

retrolefty

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

Lefty


James C4S


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))
Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

Go Up