We can only use up to three PWM at any one time ?

I was going to create a five LED Chaser with trails.

This naturally entails the requirement to PWM five LEDs at any one point in time.

void loop()
{
analogWrite(LED_5, 255);
analogWrite(LED_4, 204);
analogWrite(LED_3, 153);
analogWrite(LED_2, 102);
analogWrite(LED_1, 51);
delay(10);
//and on and on..., basically a chaser with trails.
}

But I read this from the MAKE Guide "Getting started with Arduino".
Page 56:
"Luckily, the processor used by the Arduino board has a piece of hardware that can very efficiently blinks three LEDs while your sketch does something else.
This hardware is implemented in pins 9, 10 and 11."

This is horrible news to me :frowning:

According to the Arduino Duemilanove diagram included in the guide, Pins 3, 5, 6, 9, 10 and 11 is capable of PWM, but the guide now says that at any one point in time, only three PWM can be use and they are 9, 10 and 11.

Whatever happen to 3, 5 and 6 ?

Could I use five of them at one go ?

Thanks.

Don't have the book, but it sounds nonsense to me.

No, You should be able to use all PWM pins at the same time.

I made a thing using all 6 at the beginning of september.

You can definitely use pins 3,5,6,9,10 and 11 as PWM on standard Arduino unless some library is using one or more of the timer modules for something else. timer0 controls pins 6 and 5, timer1 controls pins 9 and 10, timer2 controls 11 and 3.

Timer0 by default also drives the interrupts that provide millis(), micros(), delay() etc, but is running in a mode that supports PWM too. Some libraries use timer1 or timer2 for other purposes which can interfere with PWM, but if pins 9,10 and 11 are working this can't be the case.

Oooooooooooo

So the three timers have the ability to handle the PWM of two pins.
Now I know why there are 6 PWM pins then.

Thank you :slight_smile:

"Luckily, the processor used by the Arduino board has a piece of hardware that can very efficiently blinks three LEDs while your sketch does something else.
This hardware is implemented in pins 9, 10 and 11."

I do not think this is referring to PWM and I do not think the pin references are correct. You do not need or want PWM to blink an LED, you want to toggle the LED. Each of the timers has the capability of toggling a specific pin without using any code (after it is set up) and without using any interrupts. The outputs would be OC0A, OC1A, and OC2A which correspond to pins 6, 9 and 11 on the Arduino. I posted some (untested) code here: Arduino Forum . Now if you want "to create a five LED Chaser with trails" you may indeed need to use PWM, but that is different from 'blinking' an LED.

So the three timers have the ability to handle the PWM of two pins.

True, but this may or may not be good enough for your purposes. For each pair of pins controlled by a specific timer the PWM outputs are not totally independent.

Have you looked here? http://arduino.cc/en/Tutorial/SecretsOfArduinoPWM

Don

Ooo..

You can "manually" implement PWM on any pin by repeatedly turning the pin on and off for the desired times.

Thats great, learned something new today about PWM..