problem with pwm and led on pins 5 and 6

I have an rgb led hooked up with:

#define rPin 9 //red pin
#define gPin 5 //green pin
#define bPin 6 //blue pin

The red pin works fine with analogwrite but the green and blue pin stay on at a medium intensity despite using analogwrite to set pwm to 0.

What could cause these to stay on?

I am using these libraries:
#include <Servo.h>
#include <FrequencyTimer2.h>

but afaik neither should be interfering with the pwm on pin 5 and 6.

Any clues?

p.s. I am using Arduino 011

I haven't used that particular combination of libraries, so can't say for sure...

Perhaps a quick test sketch that uses no libraries and just tries to set PWM to max for all three LEDs would establish that it is possible to do so? After that, we'd know it's a problem with the original sketch.

I just made a new sketch that uses no libraries and a bare arduino diecimila.

All I do is fade up the pwm value and use analog write to pins 9, 5 and 6.

Pin 9 acts as a expected but pins 5 and 6 keep the led on constantly (at about half brightness) when I write a value of 0.

basically pwm control is acting totally differently and writing 0 does not turn off the output.

Does that give better clues?

Are you using current limiting resistors for your LED?

I think green & blue leds typically have different voltage drops than the red. Try reversing the colors and also using different pins (if you are using resistors).

Doesn't matter what color I put on pins 5 and 6, they behave totally differently from the other pwm channels.

It is pretty frustrating to be so short on pwm channels. SO many of the libraries I want to use eat them up (servo, frequencytimer2 etc.).

I also already have a slave arduino but it has a ladyada audio shield on it so that eats up almost all the useful pwm's as well.

I may need to multiplex the few pwms that are working properly with a CD4051.

Maybe the issues with pins 5 and 6 have been fixed in Arduino 012?

I wonder if its related to I2c? Doesn't that use pins A5 & A6? [edit]Oops! It's 4&5! (never post from work, never post from work) :-X[/edit]

I2C uses analog pins 4 and 5

I am having problems with digital pins 5 and 6

The reference page for analogWrite() states:

Notes and Known Issues

The PWM outputs generated on pins 5 and 6 will have higher-than-expected duty cycles. This is because of interactions with the millis() and delay() functions, which share the same internal timer used to generate those PWM outputs.

That could be the problem.

To check that this is so, you could check that pins 3, 10 and 11 work normally, like 9. Using free sound-card oscilloscope software you could also verify that analogWrite(3,0) and analogWrite(5,0) don’t look the same.

If you confirm that this is the problem, do you need pins 3, 10 and 11 for something else or can you use two of them instead of 5 and 6?