Hi,
Thanks for the reply.
My schematic is dead simple. It is nicely described in the picture in this thread (see a post by "Makkan").
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1236091181This is the code: (which is also quite simple)
// Declare variables for pin numbering
int r1Pin = 9;
int r2Pin = 2;
int r3Pin = 5;
int g1Pin = 10;
int g2Pin = 3;
int g3Pin = 6;
int b1Pin = 11;
int b2Pin = 4;
int b3Pin = 7;
// Declare variables for serial data read
// R1R2R3G1G2G3B1B2B3
int RR1 = 50;
int RR2 = 50;
int RR3 = 50;
int GG1 = 50;
int GG2 = 50;
int GG3 = 50;
int BB1 = 50;
int BB2 = 50;
int BB3 = 50;
void setup()
{
// Set pins for data output
pinMode(r1Pin, OUTPUT);
pinMode(r2Pin, OUTPUT);
pinMode(r3Pin, OUTPUT);
pinMode(g1Pin, OUTPUT);
pinMode(g2Pin, OUTPUT);
pinMode(g3Pin, OUTPUT);
pinMode(b1Pin, OUTPUT);
pinMode(b2Pin, OUTPUT);
pinMode(b3Pin, OUTPUT);
// open serial port
Serial.begin(9600);
}
void loop()
{
// read data from serial (MoMoLight-"protocol")
while(true){
if (Serial.available() > 8) {
RR1 = Serial.read();
RR2 = Serial.read();
RR3 = Serial.read();
GG1 = Serial.read();
GG2 = Serial.read();
GG3 = Serial.read();
BB1 = Serial.read();
BB2 = Serial.read();
BB3 = Serial.read();
}
// Write values to PWM ports (values = 0...255)
analogWrite(r1Pin, RR1);
analogWrite(r2Pin, RR2);
analogWrite(r3Pin, RR3);
analogWrite(g1Pin, GG1);
analogWrite(g2Pin, GG2);
analogWrite(g3Pin, GG3);
analogWrite(b1Pin, BB1);
analogWrite(b2Pin, BB2);
analogWrite(b3Pin, BB3);
}
}
If you have any ideas, I'd be glad to hear them. Thank you.
EDIT: And I noticed it is more clearly visible with some specific shades.