Project Home

Code Longhorn

Project LightCraft

Basic Patterns

An interesting thing to do with these lights is to make them behave in a pattern. In this section, you'll learn how to make the lights perform some basic patterns, and then you are free to create your own pattern.

Task 4.1: Blink Alternating Lights

A basic pattern is to blink every other light. Using what you've learned about loops, if-statements, and the modulus operator, add code to blink_alternating_lights() to blink every other light. Test it in the usual manner.

Task 4.2: Fading the Lights

So far, you have learned how to blinks lights and change their color. Another neat feature of these lights is their ability to fade. To fade all the lights from off to on (or vice versa), you slowly adjust the brightness. Take a look at the given function fade_brightness(). This code for this function is almost complete, but not quite. Uncomment the given code, and then modify it so that the lights fade from off to on. Test in the usual manner. (Recall that you can fade individual lights by changing their color value.)

Note that setBrightness() will scale all colors to a max value, which will prevent the colors from appearing faded. Your lights are currently set to a default value of 64 in leds_init(), so that the FastLED colors will appear more vibrant. You may change this as you wish for your project.

Now that you can fade the lights, try:

Task 4.3: Chasing Lights

One of the most recognizable patterns is that of chasing lights. In this pattern, lights light up one after another in order so that it appears the light is moving up or down the strand. You can see a sample of this in this youtube video, which shows a chase followed by a strobe.

For this task, implement a chase pattern for each strand inside the provided function chase().

Task 4.4: Chasing Lights using leds_scroll()

Above you completed the chase pattern in the typical way, but this framework actually has special support for a chase pattern across the strands. The leds data structure has not only an element for each light but also has an element for an extra light at the end of each strand (spot 7) and an element for an extra strand (also spot 7). Additionally, it provides a function, leds_scroll() that will automatically scroll the pattern for you---by shifting the characteristics of bulb y on strand x to bulb y on strand x-1.

To use these features, set your desired characteristics to the fictional bulbs in strand NUM_STRANDS and then call leds_scroll(). You'll see those characteristics propagate across the lights.

Once you have played with leds_scroll() some, implement a chase with alternating colors in the given stub function chase_two_colors_with_scroll(). This task is harder than the ones you have had previously, so be certain to carefully consider what you need to do before you begin coding.

Task 5: Create a Pattern of Your Choosing

Congratulations! You have completed all the given tasks related to controlling the lights. Now you may begin the creative part of the project by creating a pattern of your own design.

To implement your pattern, you may use the project files already found in the sketch or add new functions to the tests/tests.h files. Whichever you choose, be certain to call the appropriate functions from the loop() function in grid_framework.

After creating a pattern of your own design, you may design a pattern or a 3D creation of your choosing (using the lights, of course)! Whatever you decide to do, be sure to follow the showcase rules!

Towards the end of the week, you may want to eliminate the startup test pattern performed by the software. If you need our help to do so, just ask! We're always happy to help.