Created
October 2, 2013 15:38
-
-
Save andrew-dash/6795715 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // current RGB values | |
| float cRed; | |
| float cGreen; | |
| float cBlue; | |
| // target RGB values | |
| float tRed; | |
| float tGreen; | |
| float tBlue; | |
| // variable which denotes whether RGB is (+) or (-) | |
| float signRed; | |
| float signGreen; | |
| float signBlue; | |
| // min and max rgb values | |
| float maxRed; | |
| float minRed; | |
| float maxGreen; | |
| float minGreen; | |
| float maxBlue; | |
| float minBlue; | |
| void setup() { | |
| //Serial.begin(9600); | |
| strip.begin(); | |
| // Update LED contents, to start they are all 'off' | |
| strip.show(); | |
| cRed = random(255); | |
| cGreen = random(255); | |
| cBlue = random (255); | |
| tRed = random (255); | |
| tGreen = random (255); | |
| tBlue = random (255); | |
| if (cRed > tRed) { | |
| signRed = -1; | |
| } | |
| else { | |
| signRed = 1; | |
| } | |
| if (cGreen > tGreen) { | |
| signGreen = -1; | |
| } | |
| else { | |
| signGreen = 1; | |
| } | |
| if (cBlue > tBlue) { | |
| signBlue = -1; | |
| } | |
| else { | |
| signBlue = 1; | |
| } | |
| } | |
| void loop() { | |
| // Some example procedures showing how to display to the pixels | |
| colorPick(); | |
| } | |
| void colorPick() { | |
| cRed = cRed + (1 * signRed); | |
| cGreen = cGreen + (1 * signGreen); | |
| cBlue = cBlue + (1 * signBlue); | |
| // RED | |
| if (int(cRed) == int(tRed)) { | |
| tRed = random(255); | |
| } | |
| //println("New tRed = " + tRed); | |
| if (cRed < tRed) { | |
| signRed = 1; | |
| } | |
| else { | |
| signRed = -1; | |
| } | |
| // GREEN | |
| if (int(cGreen) == int(tGreen)) { | |
| tGreen = random(255); | |
| } | |
| //println("New tGreen = " + tGreen); | |
| if (cGreen < tGreen) { | |
| signGreen = 1; | |
| } | |
| else { | |
| signGreen = -1; | |
| } | |
| // BLUE | |
| if (int(cBlue) == int(tBlue)) { | |
| tBlue = random(255); | |
| } | |
| //println("New tBlue = " + tBlue); | |
| if (cBlue < tBlue) { | |
| signBlue = 1; | |
| } | |
| else { | |
| signBlue = -1; | |
| } | |
| //Serial.println(cRed); | |
| //delay(0); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment