Go Down

Topic: Difference between PWM pins and standard pins (Read 8060 times) previous topic - next topic



This is surely a newbeeic question, but after not finding an explanation in the reference documentation I must submit  :-[

As stated, there are 6 PWM capable digital I/O pins on the Duemilanove. PWM beeing the operation of setting the pins to HIGH and LOW consequently to form a square wave, how are these pins any different from the other D-I/O pins that also have this capability?

Im currently running a 12VDC fan of a transistor on/off circuit from pin 7 (which is not a PWM pin) and I'm able to regulate the operating voltage of the fan, thus controlling its speed, by delaying switching between HIGH and LOW on that pin. :o


The PWM pins use a built in timer to generate the square wave.  While in theory, the same thing could be achieved without a PWM pin, these pins are specifically connected to do so.

The other pins can be "hacked" to do the same thing, but it's complicated.

Both types of pins can also be used as "traditional" Digital I/O pins with HIGH or LOW settings.


Yes, it's not unlike serial communications capabilities. The standard AVR chip used in an Arduino (168/328) has internal USART hardware circuitry that is attached to only pins 0 and 1. However one can use software functions to do serial communications on any of the digital I/O pins. So it's a case that every specific AVR processor type used has built in hardware capabilities that are assigned to specific I/O pins. The AVR datasheet for a specific processor is the best source to understand the 'extra' capabilities of each and every I/O pin.



Thank you for the answers!

The other pins can be "hacked" to do the same thing, but it's complicated.

The code I use to run this "pseudo-pwm" (?) isnt very complicated at all, I might not have understood the definition completely though. Including for completion.

Code: [Select]

void setup()
pinMode(7, OUTPUT);

unsigned char speed;
unsigned int low = 1;
unsigned int high = 10;
unsigned int baseTime = 10;

void loop()


if (Serial.available())
speed = Serial.read() - 48;
low = speed;
high = baseTime - speed;


Source: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1231205087/0


Well, what I meant was modifying timers to make it possible to maintain the PWM signal whilst doing other things in the program (much as you can analogWrite(), and then do something else, maintaining the signal).


Ah, yes of course. That is a good point. Scrapping this for analogWrite(). Thank you!

Go Up