Project Home

Project Illuminate: Step 4

 

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. Not only is creating your own pattern entertaining and challenging, but you are on your way to a project!


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, then turn your cups to red so that a member of the staff can check your code, and switch drivers.


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 set the brightness scale for all lights. Your lights are currently set to a default value of 64 in setup(), so that the FastLED colors will appear more vibrant. You may change this as you wish for your project. The maximum value is 255, but colors do appear washed out at that level.

Now that you can fade the lights, try:

Once your lights are successfully fading, please turn your cups to red so that a staff member can check your code, and then switch drivers!


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 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 inside the provided function chase().

When you have this working, turn your cups to red so that a member of the staff can check your code, and switch drivers.


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 patterns such as chase.

Above you completed the chase pattern in the typical way, but this framework actually has special support for patterns such as chase. It provides a function, leds_scroll() that will automatically scroll the pattern for you---by shifting the characteristics of bulb x to bulb x-1.

To use these features, call leds_scroll() and then set the last bulb to show your new desired characteristic. You'll see that characteristic propagate down 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.

Once you're ready, turn your cups to red so that a member of the staff can check your code, and switch drivers.


Task 5: Create a Pattern of Your Choosing

Now you should create a pattern of your own design. Some basic patterns that you could implement and then extend are showcased at this website.

To implement your pattern, you may add new functions to the skeleton code, or you may create a new project entirely and only copy over the code you want to use. Whichever method you choose, don't forget to add a call to your functions from loop()!

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.

Now, turn your cups to red so that a member of the staff can check your code, and switch drivers.