// This is code for the Atmolight Slave controller // Bart Venneker 2013 // www.bartvenneker.nl int latchPin = 2; // Go Pin int dataPin = 4; // Data Pin int red,green,blue; #define RedPinTop 9 //Red pin 9 #define GreenPinTop 10 //Green pin 10 #define BluePinTop 11 //Blue pin 11 void setup() { pinMode(latchPin, INPUT); pinMode(dataPin, INPUT); } void loop(){ // wait until latch goes low // latch = red // clock = green // data = blue int pulseLenght = 100; if (digitalRead(latchPin)==HIGH) { delayMicroseconds(pulseLenght / 2); for (int pp=0; pp<8; pp++){ if (digitalRead(dataPin)==HIGH) { bitWrite(red,pp,1); }else{ bitWrite(red,pp,0); } delayMicroseconds(pulseLenght); } for (int pp=0; pp<8; pp++){ if (digitalRead(dataPin)==HIGH) { bitWrite(green,pp,1); }else{ bitWrite(green,pp,0); } delayMicroseconds(pulseLenght); } for (int pp=0; pp<8; pp++){ if (digitalRead(dataPin)==HIGH) { bitWrite(blue,pp,1); }else{ bitWrite(blue,pp,0); } delayMicroseconds(pulseLenght); } } analogWrite(RedPinTop, red); analogWrite(GreenPinTop, green); analogWrite(BluePinTop, blue); }