Step 56Software: Effect launcher
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 Step | Download PDFView All Steps | Next Step » |
![]() |
Add Comment
|

































































































![Hard Wired LED Cube: [No Programming]](http://img.instructables.com/files/deriv/FTD/SF1T/GO8DC8KW/FTDSF1TGO8DC8KW.SQUARE.jpg)














