Links and info related to creating PWM and other ways to control LED colors.
Bit Angle Modulation (BAM) vs. PWM:

http://forum.sparkfun.com/viewtopic.php?f=6&t=3210&start=15

Mirror Imaged Bit Angle Modulation (MIBAM):

http://www.picbasic.co.uk/forum/showthread.php?t=10564

Muita pwm algoritmejä:
http://www.google.com/url?sa=t&source=web&cd=1&ved=0CB0QFjAA&url=http%3A%2F%2Fwww.mosaic-industries.com%2FResources%2Fpdf%2Fmi-an-056optimalpwmalgorithm.pdf&rct=j&q=better%20pwm%20algorithm&ei=uL5rTszbE8XEswbtzc3JBA&usg=AFQjCNG70qF9QTR0UJtZKhxj4BQcUUkiAg&cad=rja
Driver IC:s & Ardu-code:

PCA9635 https://github.com/rambo/pca9635 (I2C)

using 3 to drive RGB https://github.com/rambo/pca9635RGB (a lot of optimizations to be done when I get that far [like writing all changes in single transactions as these ICs support mode where they change outputs synchronously on I2C STOP)

http://fi.rsdelivers.com/product/nxp/pca9635pw-112/led-driver-23-55v-pca9635pw/0510897.aspx

RGB Ledejä:

http://myworld.ebay.com/buynow360/?_trksid=p4340.l2559

$25 / 100 diffuse common anode RGB LEDs, jne

//// suovulan temppi:
Gammaramp 2.5 [256] ja [1024]
http://pastebin.com/C0EBBiyx
Ledejä esim:
http://www.ebay.com/itm/20-Pcs-High-Power-Warm-White-1W-Led-Lamp-Beads-80-90-Lm-/120840008460
2 ohm vastus, ~4V power supply
ja http://www.satisled.com/
----------
// Software PWM
ISR(TIMER1_OVF_vect) { // interrupt service routine that wraps a user defined function supplied by attachInterrupt
//Timer1.isrCallback();
}
void setup() {
pinMode(13, OUTPUT);
// Set Timer1, TCNT1, to 16 MHz
// This will break Arduino's analogWrite to pins X and Y
cli(); // disable interrupt
TCCR1A = 0; // No PWM is used.So set this to zero.
TCCR1B = 0 << CS12 | 0 << CS11 | 1 << CS10; // Input clock is set to clk_io/1 (No prescaling)
TIMSK1 = 1 << TOIE1; // Bit 0 – TOIE1: Timer/Counter1, Overflow Interrupt Enable
TCNT1 = 0x0000; // Reset timer counter
sei(); // enable interrupts
}
int pwmRampDelta = 1;
uint16_t pwmRampValue = 1;
uint16_t pwmRampValueMax = 1024; // 0..65535
void loop() {
pwmRampValue += pwmRampDelta;
if (pwmRampValue == 0 || pwmRampValue == pwmRampValueMax) {
pwmRampDelta = -pwmRampDelta;
}
uint16_t ticks = TCNT1;
if (pwmRampValue < ticks) {
digitalWrite(13, HIGH);
} else {
digitalWrite(13, LOW);
}
}