// by Les Hall 2013 // public domain code - use freely // global variables float timeStep = 0.0001; float time = 0.0; int redPin = 2; int greenPin = 1; int bluePin = 0; float red = 127.0; float green = 127.0; float blue = 127.0; // the setup routine runs once when you press reset: void setup() { pinMode(redPin, OUTPUT); pinMode(greenPin, OUTPUT); pinMode(bluePin, OUTPUT); } // the loop routine runs over and over again forever: void loop() { red = 127.5 + 127.0 * float(sin(17.0 * time / 3.0)); green = 127.5 + 127.0 * float(sin(13.0 * time / 5.0)); blue = 127.5 + 127.0 * float(sin(11.0 * time / 7.0)); analogWrite(redPin, int(red)); analogWrite(greenPin, int(green)); analogWrite(bluePin, int(blue)); delay(2.0); time += timeStep; if (time >= TWO_PI) { time -= TWO_PI; } }