Go Down

Topic: Arduino and PWM (Read 2838 times) previous topic - next topic


one question,
why the arduino function analogWrite only work in 6 pins?

I needed to use 7 PWM ports, so I wrote new function so that I was able to use up to 14 PWM pins.



Want to tell us anything about the function? How does it work? What timers does it use? What frequency is the duty cycle change?
The art of getting good answers lies in asking good questions.


May 23, 2010, 07:03 pm Last Edit: May 23, 2010, 07:04 pm by dansku Reason: 1
I used a part of the code found on arduino.cc website.

To make the LED fade, I used the function delayMicroseconds

worked well

Code: [Select]
     digitalWrite(j, HIGH);
       digitalWrite(j, LOW);
       delayMicroseconds(1000 - i);


May 23, 2010, 07:08 pm Last Edit: May 23, 2010, 07:10 pm by AWOL Reason: 1
And the processor load vs. using the PWM pins?
Why did you stop at 14?
What about the analogue pins?
"Pete, it's a fool (who) looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.
I speak for myself, not Arduino.


With the code snippet above, for 14 pins, you're looking at a refresh rate of around 70Hz, which will produce noticeable flicker on an LED.

The hardware pins operate at around 490Hz.
Some people are like Slinkies.

Not really good for anything, but they bring a smile to your face when pushed down the stairs.


ah, that's the difference then
but i cant see it flickering :)


Go Up