How it works...

Three different animations are presented in this recipe. When it comes to light animations, the sky's the limit. There are so many different ways to control color change and timing and each different approach will create a slightly different visual effect. However, a key aspect of all animation is timing; we can control the pace of the animation by using the sleep call, which is part of the time module. In this way, we can slow down or speed up the animations we create.

The first animation in this recipe is a simple for loop, which sets the color of each pixel to a random color and pauses for one second between these color changes. The second animation builds on the first one by having an outer loop that loops 3 times and so changes the pixels 30 times.

Finally, the last animation takes a different approach by setting all the pixels to the same color and then changing them together during each loop.