ALA Example - MultiAnimations

This is one of the examples to the Arduino Light Animation (ALA) library.

Example to demonstrate how to drive different set of LEDs independently using Arduino PWM output pins a TLC5940 chip and an WS2812 strip.

In this video you can see:

  • two red LEDs driven by PWM output pins
  • three cyan LEDs driven by a TLC5940 chip
  • three RGB LEDs driven by the TLC5940 chip
  • 8 RGB LEDs in a WS2812 strip






#include "AlaLed.h"
#include "AlaLedRgb.h"

byte tlcPins1[] = { 1, 2, 3 };
byte tlcPins2[] = { 6,7,8, 9,10,11, 12,13,14 };

AlaLed led1;
AlaLed led2;
AlaLed someLeds;
AlaLedRgb rgbLeds;
AlaLedRgb rgbStrip;


void setup()
{
  led1.initPWM(5);
  led2.initPWM(6);
  someLeds.initTLC5940(3, tlcPins1);
  rgbLeds.initTLC5940(3, tlcPins2);
  rgbStrip.initWS2812(8, 2);

  led1.setAnimation(ALA_STROBO, 1000);
  led2.setAnimation(ALA_GLOW, 5000);
  someLeds.setAnimation(ALA_PIXELSMOOTHSHIFTLEFT, 2400);
  rgbLeds.setAnimation(ALA_FADECOLORSLOOP, 12000, alaPalRgb);
  rgbStrip.setAnimation(ALA_COMETCOL, 5000, alaPalRgb);
}

void loop()
{
  led1.runAnimation();
  led2.runAnimation();
  someLeds.runAnimation();
  rgbLeds.runAnimation();
  rgbStrip.runAnimation();
}


2 comments:

  1. Hello and many thanks you for your great work.

    I have a problem understanding the role of the "ALA_ENDSEQ" keyword inside a sequence array, because using it doesn't change anything.
    Also, what happens when you launch multiple animations of different durations ?

    Regards,

    ReplyDelete
    Replies
    1. The ALA_ENDSEQ keyword should mark the end of the animation sequence and tell ALA to start from the beginning.
      I don't think you can avoid to use it. In line 93 of AlaLed.cpp you will find this line that initializes the animation lenght.
      for(animSeqLen=0; animSeq[animSeqLen].animation!=ALA_ENDSEQ; animSeqLen++)

      If you run different animations with different lengths you will loode sync after the first cycle but everything will work. This similar to what you see in the video.

      Delete

Note: Only a member of this blog may post a comment.