Ive been using Pyranha RGBs in a recent project. They have a common anode which you wire to about 3V ish if i remember right. (I think I used a 60ohm resistor to 5V). Then you wire the the R, G and B pins to the PWM pins on your arduino. When tied LOW the current flows from the anode into the arduino and you get light. So you then have to use the analogWrite command to balance (effectivly fade) the different colours. I used this code to control the colour with 3 pots, then a push switch to tell me what the values I was using were:
const int Switch = 13;
const int ROne = 11;
const int GOne = 10;
const int BOne = 9;
const int RIn = A4;
const int GIn = A2;
const int BIn = A0;
int RPotValue = 0;
int RLEDValue = 0;
int GPotValue = 0;
int GLEDValue = 0;
int BPotValue = 0;
int BLEDValue = 0;
int SwitchState = LOW;
void setup(){
Serial.begin(9600);
pinMode(Switch, INPUT);
pinMode(ROne, OUTPUT);
pinMode(GOne, OUTPUT);
pinMode(BOne, OUTPUT);
pinMode(RIn, INPUT);
pinMode(GIn, INPUT);
pinMode(BIn, INPUT);
}
void loop(){
RPotValue = analogRead(RIn);
RLEDValue = map(RPotValue, 0, 1023, 0, 255);
analogWrite(ROne, RLEDValue);
GPotValue = analogRead(GIn);
GLEDValue = map(GPotValue, 0, 1023, 0, 255);
analogWrite(GOne, GLEDValue);
BPotValue = analogRead(BIn);
BLEDValue = map(BPotValue, 0, 1023, 0, 255);
analogWrite(BOne, BLEDValue);
SwitchState = digitalRead(Switch);
if(SwitchState == HIGH) {
Serial.print (" R");
Serial.print (RLEDValue);
Serial.print (" G");
Serial.print (GLEDValue);
Serial.print (" B");
Serial.print (BLEDValue);
Serial.print (" ");
delay (2000);
}
else {
delay(50);
}
}
Because the output pins are cathodes, a signal of 0 for PWM is full on, and 255 is full off, reverse to normal.
So you need the map function to turn the number of emails you have into a number between 0 and 255, then you need the analogWrite function to feed that value to the LEDs, (So from Red to green would be Red 0 going to 255, and Green 255 going to 0. So at 500 emails you should have Red 127, Green 127. Does that make sense?
drop me an PM for clarity if you like.