Go Down

Topic: Arduino and PWM (Read 716 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?


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


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.
Per Arduino ad Astra


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


Go Up

Quick Reply

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

Note: this post will not display until it's been approved by a moderator.

shortcuts: alt+s submit/post or alt+p preview