Pages: [1]   Go Down
Author Topic: Arduino mega PWM output pins  (Read 602 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17262
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Austin, TX
Offline Offline
Faraday Member
**
Karma: 71
Posts: 6119
Baldengineer
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


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

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

Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17262
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Lefty

Logged

Austin, TX
Offline Offline
Faraday Member
**
Karma: 71
Posts: 6119
Baldengineer
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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))
Logged

Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

Pages: [1]   Go Up
Jump to: