Go Down

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

dansku

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.

Thanks

PaulS

Want to tell us anything about the function? How does it work? What timers does it use? What frequency is the duty cycle change?

dansku

#2
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]
   for(i=1;i<=1000;i++){
     digitalWrite(j, HIGH);
     delayMicroseconds(i);
       digitalWrite(j, LOW);
       delayMicroseconds(1000 - i);
   }

AWOL

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

Groove

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

dansku

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

Grumpy_Mike


Go Up