Step 1 - Build the Project
Fade the entire LED strip's brightness up and back down using the .setPixel method().
Step 2 - Upload the Code
Step 3 - Read the Walkthrough
The LED Strip library is a separate file of code. It contains functions and methods that are specific to controlling a strip of LEDs. To use the library, you use the #include statement. Then, you have to give the library some information, similar to setting pinMode() for components.
To tell the LEDStrip library the name & attributes of your LED Strip, you create an object. In this case, the object is called ‘strip’ and it has 15 pixels, the data pin is number 13, and the clock pin is number 12 on your carrier board.
Next, you’ll use two variables for the values that will be changing throughout your program.
The first variable is an integer for the brightness value. It is basically a percentage of power being sent to the strip.
The brightnessChange value is the size of the steps between brightness levels that your code will take. You can modify this to anything below 100.
In the loop, the brightness variable is constantly updating for the entire strip. The .setPixel method takes in which pixel to address—in this case, all of them — what color to write those pixels , and what the brightness should be.
Next, check if the brightness level has passed or reached 0 or 100. If either of those things is true, multiple brightnessChange by -1 so that if the light was dimming, it will start brightening and vice versa.
After the if statement, the brightness level is updated by brightnessChange. Depending on whether brightnessChange is positive or negative, the brightness value will grow or shrink.
Now the strip.draw() command pushes the pixel, color, and brightness value to the strip. This is the first time in the loop that you should actually see the effects of your .setPixel values.
The delay affects how fast the brightness values update. Change this to see how the delay affects the program differently than how the brightnessChange variable affects the program.