Fades in sequences are the magic that makes LED effects look like the real world. In this section, we will cover two forms of the Fade command, Fade From and Fade To.

Fade From

Let’s start with constants, then convert to fades. A very simple sequence is one that blinks an LED every two seconds:

//simple blinking using constants

blinkLoop    Chn1 = 100%  //turn fully on for 1s
@+1s         Chn1 = 0%    //turn off for 1s
@+1s         go to blinkLoop

This sequence doesn’t fade. The instant on and off is rather harsh and digital looking. What would it take to fade instead? We have merely to replace each constant with a Fade From command:

//Blinking has been converted to quarter-second fades
//simply replacing the constant with the fade 
fadeLoop     Chn1 = fade from 0% to 100% for 0.25s  //presto blinko, now it's a fade
@+1s         Chn1 = fade from 100% to 0% for 0.25s  //each fade takes one-half second
@+1s         Go To fadeLoop

That was easy.  If we lengthen the fade time, it looks like something else. Perhaps an alien, glowing thing:

//Never stands still. Always fading up and down looks like eerie alien glow

alienLoop   Chn1 = fade from 0% to 100% for 1s        //longer fades
@+1s        Chn1 = fade from 100% to 0% for 1s        //Each fade takes one second
@+1s        Go To alienLoop

Otherworldly!

By greatly shortening the fade time, it brings us down to Earth. And back to the last century. This looks like an incandescent light bulb turning on and off.

//Fast fade looks like incandescent light bulb

bulbLoop    Chn1 = fade from 0% to 100% for 120ms //milliseconds more convenient to use
@+1s        Chn1 = fade from 100% to 0% for 120ms //Each fade takes 0.120 seconds
@+1s        Go To bulbLoop

We end at the beginning. Fades become identical to constants when we reduce the fade time to zero:

//fades shortened back to blinks 
blinkLoop    Chn1 = fade from 0% to 100% for 0ms   //Instant on 
@+1s         Chn1 = fade from 100% to 0% for 0ms   //Instant off 
@+1s         Go To blinkLoop

If we wanted to fade manually, we might do it like this:

//misguided effort at a fade

poorFadeLoop Chn1 = 0%
@+0.1s       Chn1 = 10%
@+0.1s       Chn1 = 20%
@+0.1s       Chn1 = 30%
@+0.1s       Chn1 = 40%
@+0.1s       Chn1 = 50%
@+0.1s       Chn1 = 60%
@+0.1s       Chn1 = 70%
@+0.1s       Chn1 = 80%
@+0.1s       Chn1 = 90%
@+0.1s       Chn1 = 100%
@+0.1s       Chn1 = 90%
@+0.1s       Chn1 = 80%
@+0.1s       Chn1 = 70%
@+0.1s       Chn1 = 60%
@+0.1s       Chn1 = 50%
@+0.1s       Chn1 = 40%
@+0.1s       Chn1 = 30%
@+0.1s       Chn1 = 20%
@+0.1s       Chn1 = 10%
@+0.1s       Go To poorFadeLoop

But that makes a very choppy fade and it was a lot of work to write (let’s agree never to do that again!).

By comparison, fades are much smoother, more easily adjusted and do not take so many lines to write.

There’s one other great feature to fades, it’s on autopilot. We don’t have to wait for them to finish. Here are several overlapping fades that are only possible because of that feature:

//simultaneous, overlapping fades take care of themselves automatically
//we start each fade but don't wait for it to finish

@+1s        Chn1 = fade from 4.4% to 50% for 10s
@+1s        Chn2 = fade from 0% to 100% for 2s
@+1s        Chn3 = fade from 49% to 51% for 60s
@+1s        Chn1 = fade from 50% to 100% for 5s  //replaces earlier fade in progress

In the last line, channel 1 interrupts a fade already in progress on the same channel. That’s okay, the sequence player simply abandons the old fade at whatever brightness it was at that moment and replaces it with the new fade.

This particular overlapping fade caused a sudden brightness jump, because the first fade hadn’t gotten to 50% yet and the second one started at 50%. That is usually undesirable.

We could have calculated the correct fades in this case but that can not always be done. If several Go To statements coming from elsewhere in the sequence jumped to this line, the fade may be starting with a brightness that is different each time. There is a solution: The Fade To command. It starts the fade where it last left off.

Fade To

In cases where you can’t calculate the starting brightness of a fade, the Fade To command can be used.

//Candle in a drafty space
//randomly disrupts the rising or falling flame
//smoothly fades to different brightnesses, almost never reaching final value

brightness1  chn1 = fade to 100% within 1s          //bright flicker
@+75ms       go between brightness1 and brightness2 //equally likely choices
brightness2  chn1 = fade to 50% within 1s           //semi-dim flicker
@+75ms       go between brightness1 and brightness2 //equally likely choices

Fade To differs from the Fade From statement in two ways.

  1. It has no “From” starting brightness. Instead, it starts with the brightness contained in the channel itself,
  2. The fade time is not precisely known, that is why we say “within” a time period.

The Within time is only true if the fade covers the full 100% brightness range. Over a 50% range, the fade takes half as long, and so forth. Like a stage hand working a light dimmer, we know how fast he will turn down the lights, but we don’t know the lever’s initial position. Therefore, we don’t know how long the fade takes.

We often just need the fade to be plenty long to do the job. The candle was one example. Here are two more:

  • An arc welder works with a blinding tip. It flashes and strobes randomly on channel 1. Meanwhile, channel 2 depicts the surrounding metal slowly glowing brighter as it heats up and glowing dimmer as it cools. Channel 2 uses Fade To commands to slowly rise and fall according to arc intensity and strobe frequency.
  • A creature’s heartbeat in the lab races faster and slower on channel 1 according to a fixed or random pattern. Fade To commands on channel 2 slowly follow those beats so that the brightness depicts the average pulse rate.

This is a simple arc welder:

//Arc Welder
//Chn1 flashes 
//Chn2 metal gets red hot

@0ms spark 
              //make spark and heat up metal
              Chn1 = 100%                        //spark
              Chn2 = fade to 100% within 1.5s    //heats up fast

@+20ms        //spark duration
              
              //make gap between sparks and cool down metal
              Chn1 = 0%                         //gap between sparks
              Chn2 = fade to 0% within 5s       //cools down slow
              
@+20ms        //minimum gap duration. May be lengthened below.

              go to endGap with 95% chance      //short gap: usually a shower of sparks
moreGap
@+150ms       go to moreGap with 90% chance     //longer gap: Less frequent sparks or longer pauses
endGap
              go to spark                       //done with gap, make another spark

Since sparks are shorter than gaps on average, we needed the fade up to be faster than fade down. The initial times were estimated ideas only. Then they were adjusted to our liking by trial and error.

Other Details

Brightness is given in percent, 0 to 100%. The optional percent sign adds to readability. Fractional percentages are allowed as long as a number precedes the decimal point (use 0.5%, not .5%). Half percents are reliably depicted, but finer fractions sometimes round off to the same brightness. For programmers, brightness may also be given in the following notation: 0x00 through 0xff.

Fade durations may be given in seconds (1.5s) or milliseconds (1500ms). The ms suffix adds to readability but may be left off. Decimal points are allowed but must be preceded by a digit (0.5s, not .5s).

The longest fade is 72,000 seconds, 20 hours. About the only way to see that is to start a fade on a channel that is never touched again:

//uberlong fade, 20 hours
//fades once. Reset power to fade again

              chn1 = fade from 100% to 0% for 72000s

waitAllDay    //stays here
@+5ms         go to waitAllDay

Conclusion

We learned that Fades have a lot of character! We can change their meaning merely by adjusting the numbers. And they take us from a rigid digital look to all different kinds of smooth real world effects.

These examples can be copied and pasted into Sequence Composer, modified, checked for errors and saved to disk. By adding a ComLink and Morsel, you can watch them run and frankly, be amazed at how much a few lines can do.

 

Back to Menu

 

 

 

 

Go to home page