RGB "Blinky" question about ground

So, I've written my first program, designed to operate an RGB LED and display the primary colors in sequence. I assembed the board and resistors on the breadboard and uploaded the program and......... nothing. Nada. So I uploaded the trusty old Blinky example and used Pin 13. Still nothing. Kept playing and found my LED is a common Positive (anode, cathode, I can never remember which). I could drive to Radio Shack and buy a common negative, but that will teach me nothing. Is there a way to turn the I/O pins to ground?

[color=#7E7E7E]/*My First Project[/color]
[color=#7E7E7E]Uses a single RGB to cycle through three colors.[/color]
[color=#7E7E7E]*/[/color]

[color=#CC6600]void[/color] [color=#CC6600][b]setup[/b][/color]() {
  [color=#CC6600]pinMode[/color](9, [color=#006699]OUTPUT[/color]);
  [color=#CC6600]pinMode[/color](10, [color=#006699]OUTPUT[/color]);
  [color=#CC6600]pinMode[/color] (11, [color=#006699]OUTPUT[/color]);
} 

[color=#CC6600]void[/color] [color=#CC6600][b]loop[/b][/color]() {
  [color=#CC6600]digitalWrite[/color](9, [color=#006699]HIGH[/color]);
  [color=#CC6600]digitalWrite[/color](11, [color=#006699]LOW[/color]);
  [color=#CC6600]delay[/color](500);
  [color=#CC6600]digitalWrite[/color](10, [color=#006699]HIGH[/color]);
  [color=#CC6600]digitalWrite[/color](9, [color=#006699]LOW[/color]);
  [color=#CC6600]delay[/color](500);
  [color=#CC6600]digitalWrite[/color](11, [color=#006699]HIGH[/color]);
  [color=#CC6600]digitalWrite[/color](10, [color=#006699]LOW[/color]);
  [color=#CC6600]delay[/color](500);
}

Don't use the "copy for forum" option in the IDE. Or if you do, wrap the result with "quote" tags instead of "code" tags.

Like this?

/*My First Project Uses a single RGB to cycle through three colors. */

void setup() { pinMode(9, OUTPUT); pinMode(10, OUTPUT); pinMode (11, OUTPUT); }

void loop() { digitalWrite(9, HIGH); digitalWrite(11, LOW); delay(500); digitalWrite(10, HIGH); digitalWrite(9, LOW); delay(500); digitalWrite(11, HIGH); digitalWrite(10, LOW); delay(500); }

With a common anode ("common positive"), the LED turns on with a LOW; with analogWrite brightest is with '0' and '255' is 'off'. Put the CA to +5 and each color to an output pin (via a resistor, each ).

Thanks!! Got it working and you taught me a new skill! Yay!!

One more question, if I may; I tried dimming the leds by running the "on" value from 0 to 200 and I noticed no change. But I taught my self variables!! Code follows:

/*RGB Cycle Makes RGB LED cycle through colors continuously. Written By JohnnyRocket */

const int red = 9; const int green = 10; const int blue = 11;

int time = 1500; int on = 200; int off = 255;

void setup(){ pinMode(red, OUTPUT); pinMode(green, OUTPUT); pinMode(blue, OUTPUT); }

void loop() { analogWrite(red,on); delay(time); analogWrite(green,on); delay(time); analogWrite(red,off); delay(time); analogWrite(blue,on); delay(time); analogWrite(green,off); delay(time); analogWrite(red,on); delay(time); analogWrite(green,on); delay(time); analogWrite(blue,off); analogWrite(green, off); }

Don't use 'copy for forum'. Just select all the text in the IDE window and copy it.

Fixed it!! (The code quote, not the dimmer)

rocketman247: Fixed it!! (The code quote, not the dimmer)

Not Quite. The code should be surrounded by CODE tags rather than QUOTE tags.

rocketman247: One more question, if I may; I tried dimming the leds by running the "on" value from 0 to 200 and I noticed no change. But I taught my self variables!! Code follows:

/*RGB Cycle
Makes RGB LED cycle through colors continuously.
Written By JohnnyRocket
*/

const int red = 9; const int green = 10; const int blue = 11;

int time = 1500; int on = 200; int off = 255;

void setup(){   pinMode(red, OUTPUT);   pinMode(green, OUTPUT);   pinMode(blue, OUTPUT); }

void loop() {   analogWrite(red,on);   delay(time);   analogWrite(green,on);   delay(time);   analogWrite(red,off);   delay(time);   analogWrite(blue,on);   delay(time);   analogWrite(green,off);   delay(time);   analogWrite(red,on);   delay(time);   analogWrite(green,on);   delay(time);   analogWrite(blue,off);   analogWrite(green, off); }

Looks like you are going from 200 to 255. Not 0 to 200.