Created
January 19, 2020 17:10
-
-
Save jlamch/c4c9558bce21d7d08ca1ba76cf78184d to your computer and use it in GitHub Desktop.
This file contains 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
#include "RGB_LED.h" | |
RGB_LED rgbLed; | |
unsigned int rgbColour[3]; | |
void setup() { | |
rgbLed.setColor(0, 0, 255); | |
} | |
void loop() { | |
delay(1000); | |
rgbLed.turnOff(); | |
delay(2000); | |
int32_t countFrom = 10; | |
for(int32_t iter = countFrom; iter >= 0; iter--) { | |
// Start off with red. | |
rgbColour[0] = 255; | |
rgbColour[1] = 0; | |
rgbColour[2] = 0; | |
// Choose the colours to increment and decrement. | |
for (int decColour = 0; decColour < 3; decColour += 1) { | |
int incColour = decColour == 2 ? 0 : decColour + 1; | |
// cross-fade the two colours. | |
for(int i = 0; i < 255; i += 1) { | |
rgbColour[decColour] -= 1; | |
rgbColour[incColour] += 1; | |
rgbLed.setColor(rgbColour[0], rgbColour[1], rgbColour[2]); | |
delay(3); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment