14 Fade APA Colors

Variable Pixel Color Spectrum

/* Fade through all the colors of the rainbow LED pixels with a variable */ #include "LEDStrip.h" //The LEDStrip.h library gives your code access to special functions exclusive to the LED pixels LEDStrip pixels = LEDStrip(4, 13, 12); //Set up the pixels by defining how many pixels (4) and where the pixels connect to the microchip int color = 0; //create a variable that will determine the color showing on the pixels void setup() {}//nothing needed in the setup! void loop() { pixels.setPixel(pixels.All, color); //use pixels.All in the place where the pixel number normally goes, then the color (0-300) pixels.draw(); //Send the setPixel values to the rainbow LEDs color++; //increase the variable by 1 delay(20); //Wait 20 milliseconds with the pixels lit up as each color if(color == 299){ //once the color value reaches the max that the pixels can show... color = 0; //reset the variable to 0 and start rising all over again. } } // (c) 2024 Let's Start Coding. License: www.letsstartcoding.com/bsdlicense
 

Walkthrough Video

Watch the video for a line-by-line explanation of how the example program works. Then you'll be ready to make some changes of your own!

LED Pixel Color Spectrum


Use this spectrum to estimate the color values you'll need for your 'setPixel' arguments to achieve your favorite color!


 

Challenges

Can you complete the challenges? Change the code in your code editor above. Upload your code to see the effect when you're finished. Complete a challenge? Check it off the list!



TRANSFORMERS and HASBRO and all related trademarks and logos are trademarks of Hasbro, Inc. ©2024 Hasbro.