int ledRED = 9; int ledGREEN = 10; int ledBLUE = 11; int nowR = random(0, 255); int nowG = random(0, 255); int nowB = random(0, 255); int toR = random(0, 255); int toG = random(0, 255); int toB = random(0, 255); void setup() { pinMode(ledRED, OUTPUT); pinMode(ledGREEN, OUTPUT); pinMode(ledBLUE, OUTPUT); } void loop() { setColor(nowR, nowG, nowB); if(nowR == toR) toR = random(0, 255); if(nowG == toG) toG = random(0, 255); if(nowB == toB) toB = random(0, 255); if(nowR < toR) nowR++; else nowR--; if(nowG < toG) nowG++; else nowG--; if(nowB < toB) nowB++; else nowB--; delay(10); } void setColor(int red, int green, int blue) { analogWrite(ledRED, red); analogWrite(ledGREEN, green); analogWrite(ledBLUE, blue); }