RGB LED and PWM pins does not work properly

Hi everybody!

I have this image which describes the cables I've "attached" to my Arduino Mega to control an RGB LED.
I get something very strange:
when I write

analogWrite(RED, 0)

the LED becomes red and not set the RED component of the color to 0.
I'm a bit confused... :~ :~
If I write

analogWrite(RED, 255)

the LED turn itself off.
(in these examples, the others colors are set to 0. Really.... 0. They are not visible).

I have an Arduino Mega and I've connected the RED to 8, GREEN to 9 and BLUE to 10 and Ground to 5V port.

What is the mistake?

Thanks a lot!

Jymmy

Common anode LED?
The behaviour you describe sounds perfectly normal.

I've seen some tuts that explain that I have to set the colour with analogWrite([i]colour[/i], 0 if I have to turn off that colour and vice versa.
So that seemed a strange behavior. To avoid errors, I post the image of my led here (it's attached!)

Thanks.

immagine010.jpg

If the LED is common anode ( impossible to tell from the photo) then the analogWrite sinks current, so the action of analogWrite is inverted - 0 turns the LED on full, and 255 turns it off.
If you want to write, say, 25/255 brightness, and a variable "brightness" contains 25, then analogWrite (redPin, 255 - brightness);