Go Down

Topic: Uh oh - RGB common Anode? (Read 646 times) previous topic - next topic

cjdelphi

I just got 20 RGB led's and the common shared pin is the Anode (+) ...

so to make Green come on, you connect the green through a resistor to - and viola...

But this is the opposite to what i'm used to lol, so if i have to DigitalWrite(pin,LOW) to switch it on, does this mean i have to also control the common anode pin? or just run it from
the + rail?.. so i have to have outputs on High to prevent the LEDS on? or switch the common anode pin to LOW to control each individual diode?

cjdelphi

#1
Sep 19, 2012, 08:53 am Last Edit: Sep 19, 2012, 09:33 am by cjdelphi Reason: 1
Code: [Select]

/*
 Blink
 Turns on an LED on for one second, then off for one second, repeatedly.

 This example code is in the public domain.
*/

void setup() {                
 // initialize the digital pin as an output.
 // Pin 13 has an LED connected on most Arduino boards:
 pinMode(2, OUTPUT);    
 pinMode(3, OUTPUT);    
 pinMode(4, OUTPUT);      
 digitalWrite(2, LOW);   // set the LED on  
 delay(200);
 digitalWrite(3, LOW);   // set the LED o
 delay(200);  
 digitalWrite(4, LOW);   // set the LED on n
 delay(1000);
 
 
}



void loop() {
 digitalWrite(2, LOW);   // set the LED on
 delay(1000);              // wait for a second
 digitalWrite(2, HIGH);    // set the LED off
 delay(1000);              // wait for a second
 digitalWrite(3, LOW);   // set the LED on
 delay(1000);              // wait for a second
 digitalWrite(3, HIGH);    // set the LED off
 delay(1000);              // wait for a second
 digitalWrite(4, LOW);   // set the LED on
 delay(1000);              // wait for a second
 digitalWrite(4, HIGH);    // set the LED off
 delay(1000);              // wait for a second
 
 
}


i quickly modified the blink sketch..

this "works" first the red then the blue then the green, etc etc..

but, when the pin is "High" what's happening, because the common anode (+ 5v) is connected to the shared RGB pin, when the negative comes on
(eg, from HIGH to LOW), the circuit conducts and the diode turns on... but when both the Anode +5v and Cathode (0v becomes) 5v, should i be worried
it's not a short is it? anything i need to worry about?..

each cathode pin is connected with a 300ohm series resistor... (5v rail from the Arduino)

Hexadec

When the pin is high it should be at the same potential as VCC so no...it's not a short it just turns the diode off (no potential difference so no current can flow).

Well worked out BTW  :smiley-mr-green:

You might be interested in looking up charlieplexing  8)
Sponge.
I'm allowed to have it 'cos it's not sharp.

Go Up