Pages: [1]   Go Down
Author Topic: Uh oh - RGB common Anode?  (Read 625 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Edison Member
*
Karma: 29
Posts: 2441
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Offline Offline
Edison Member
*
Karma: 29
Posts: 2441
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
/*
  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)
« Last Edit: September 19, 2012, 02:33:49 am by cjdelphi » Logged

Southport UK
Offline Offline
Full Member
***
Karma: 1
Posts: 195
Been at it a long time...still learning every day.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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  smiley-cool
Logged

Sponge.
I'm allowed to have it 'cos it's not sharp.

Pages: [1]   Go Up
Jump to: