3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.

LED Cube 8x8x8

Step 56Software: Effect launcher

Software: Effect launcher
We wanted an easy way to run the effects in a fixed order or a random order. The solution was to create an effect launcher function.

launch_effect.c contains the function launch_effect (int effect).

Inside the function there is a switch() statement which calls the appropriate effect functions based on the number launch_effect() was called with.

In launch_effect.h EFFECTS_TOTAL is defined. We set it one number higher than the highest number inside the switch() statement.

Launching the effects one by one is now a simple matter of just looping through the numbers and calling launch_effect(), like this:

while(1)

for (i=0; i < EFFECTS_TOTAL; i++)
{

launch_effect(i);

}

}

This code will loop through all the effects in incremental order forever.
If you want the cube to display effects in a random order, just use the following code:

while (1)
{

launch_effect(rand()%EFFECTS_TOTAL);

}

The %EFFECTS_TOTAL after rand() keeps the random value between 0 and EFFECTS_TOTAL-1.
« Previous StepDownload PDFView All StepsNext Step »

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
651
Followers
7
Author:chr
I like microcontrollers and LEDs :D