activating 4 PWMs on Arduino Uno

Hi,
I've successfully enabled 3 PWMs simultaneously, but when I set the 4th, I get a digital output (0 for any write other than 0xff).
How can I enable 4 PWMs?
Thanks,

Which pins are you using? I think there are 6 pwm pins on Uno, but other pins cannot (normally) do pwm.

I use 3,9,10,11. All PWM and works fine when I activating the separately, e.g. 9,10,11 behaves normal, but when I'm activating 3, 9 behaves like digital output:

int redPin= 10;
int greenPin = 11;
int bluePin = 9;
int servoPin = 3; 

Servo Servo1; 
void setup() { 
  Servo1.attach(servoPin);
  pinMode(redPin, OUTPUT);
  pinMode(greenPin, OUTPUT);
  pinMode(bluePin, OUTPUT); 

}

void loop(){
  uint8_t rgb[3]=...
  analogWrite(redPin, rgb[0]);
  analogWrite(greenPin, rgb[1]);
  analogWrite(bluePin, rgb[2]);
   Servo1.write(someIntValue); 
}

For future reference, you should always post your complete code. Forum members don't want to waste their time looking for a problem that could be in the part of the code you didn't post.

In this case, I think I can guess what the problem is. Pin 3 is not being used for pwm in the sense that the other pins are being used, to dim LEDs. It is controlling a servo. In the strictest sense, this signal is also pulse-width modulated, but to a quite different set of rules.

I think if you move either the servo or the green led to pin 5 or 6, that should work.

The reason for this is that the 6 pwm pins are controlled by only 3 timer circuits inside the chip. One timer controls pins 5, 6, another timer controls pins 9, 10 and the third timer controls pins 3, 11. If both pins attached to the same timer are both are used to dim LEDs or both used to control servos, fine, but if you try to control one led and one servo on the same timer, the timer settings required conflict.

From the Servo reference documentation Servo - Arduino Reference
"On boards other than the Mega, use of the library disables analogWrite() (PWM) functionality on pins 9 and 10, whether or not there is a Servo on those pins"

Sometimes it's worth reading the documentation.

Steve

Good spot Steve.