bicycle turn signal

sample animation for elektra simulator

This animation uses only 1 thread. Mirror the LED numbers to reverse direction.

 Loading animation...

Glowscript:

// DEVICE (modify with care)

 

    // Elektra simulator

    device: name = 'simulator-elektra-20'

    device: type = 'sim'

    device: tickIntervalMillisecs = '50'     // increase to reduce CPU load.

    device: protocolVersion = '1.0'

    device: ledCount = '20'

    device: ramSpaceBytes = '25000'          // set an animation size limit in memory.

    device: romSpaceBytes = '200000'         // set an animation size limit on disk.

 

// DEFINES (modify as needed)

 

    // LED defines:

    define: chevron1Leds = '[10,18,19]'      // alias for leftmost chevron leds in animation.

    define: chevron2Leds = '[9,11]'

    define: chevron3Leds = '[8,12,17,20]'

    define: chevron4Leds = '[5,6,7,13,16]'

    define: chevron4TipLed = '[6]'           // alias for rightmost chevron led in animation.

    define: allLeds = '[1-20]'

 

    // Color defines:

    define: red = '(255,0,0,1)'

    define: green = '(0,255,0,1)'

    define: blue = '(0,0,255,1)'

    define: yellow = '(10,10,0,1)'

    define: white = '(4,4,4,1)'

    define: orange = '(255,80,0,1)'

    define: purple = '(10,0,10,1)'

    define: off = '(0,0,0,1)'

 

// CODE

 

// Executes the animation instructions sequentially in a continuous loop.

@start                                                 // mandatory entry-point func name.

    here: start_tag                                    // set bookmark.

    glowImmediate: chevron4TipLed orange               // set led(s) to orange.

    glowRamp: chevron1Leds orange to off in 150ms      // set led(s) to orange then fade off.

    glowRamp: chevron2Leds orange to off in 150ms      // set led(s) to orange then fade off.

    glowRamp: chevron3Leds orange to off in 150ms      // set led(s) to orange then fade off.

    glowRamp: chevron4Leds orange to off in 150ms      // set led(s) to orange then fade off.

    call: @flashChevron4Leds (repeat=5)                // synchronously call func 5 times.

    glowImmediate: allLeds off                         // turn off led(s).

    pause: 250ms                                       // pause for 250 milliseconds.

    goto: start_tag                                    // loop back to bookmark.

 

// Flashes LED(s) once then exits.

@flashChevron4Leds

    glowImmediate: chevron4Leds orange  // set led(s) to orange.

    pause: 50ms                         // pause for 50 milliseconds.

    glowImmediate: chevron4Leds off     // turn off led(s).

    pause: 50ms                         // pause for 50 milliseconds.