Arduino Light Animation (ALA)

Arduino Light Animation (ALA) is a library for Arduino boards simplify the development of light animations using a wide variety of LEDs and LED strips.

Download ALA library here. Source code is hosted on GitHub.

Features

  • Pure Arduino implementation. No external software is needed on the PC to design and drive light animations.
  • Support for monochrome LED, RGB LED, multiple LEDs and addressable RGB LED strips using PWM output pins, WS2812 RGB LED strips and TLC5940 chips.
  • Lots of cool animations ready to use.
  • Precise timing to allow synching animations to music.
  • No use of delay() to allow to drive multiple channels and lines independently.

Examples

LEDs
  • SimpleLed - A very simple example about how to fade one LED using ALA library.
  • MultiLedSequence - Demonstrates the use of animation sequences to animate 5 LEDs using Arduino PWM outputs.
RGB LEDs
  • SimpleRgbLed - Color-fading animation for one RGB LED.
  • RgbLedSequence - Animation sequence for one RGB LED. The example also shows how to create and use a custom color palette.
Addressable RGB LED strips (WS2812)
TLC5940
Advanced


36 comments:

  1. Hey,
    Is it possible to set the minimum and maximum brightness in fading and glow animation.

    ReplyDelete
    Replies
    1. You can set the maximum brightness using the setBrightness method.
      Look at SimpleRgbLed example. A similar method is available in AlaLed class and accepts a 0-255 value.
      No method is available to set the minimum brightness.

      Delete
  2. Is the library designed for Common Cathode or Common Anode RGB LEDs? i.e. If I set 0x00FFFF, which one will display BlueGreen (Teal?), and which will display Red.

    ReplyDelete
    Replies
    1. The library is designed for common cathode RGB leds.
      You can set the pins to be used in the initPWM method. Look at this example http://yaab-arduino.blogspot.com/p/ala-example-simplergbled.html
      So... 0xFF0000 should be red, 0x00FF00 should be green, 0x0000FF should be blue.
      If colors are not matching you have to change the order of pins in the initPWM method.

      Delete
  3. is there a possibility to use ws2801 led strips? i.e. to also assign a clock pin? did not find anything in your docs. thx

    ReplyDelete
  4. Hi, is it possible to initialise 2 separate WS2812 strips on different pins, and control the animations on those strips independently?

    ReplyDelete
    Replies
    1. It should be possible but I have never tried.

      Delete
    2. did you manage to connect 2 strips on different pins?

      Delete
    3. I tried to connect few ws2812 strips. but, as soon as I define an aditional strip with initWS2812, nothing works.
      Has anyone managed to run few WS2812 strips with different pwm pins?

      Delete
    4. my "not working" example is at https://github.com/Feng-GUI/experience/blob/master/LedSign/LedSign.ino

      Delete
    5. I tried this using two LED matrices today (on D2 and D3) on a nano 328 16Mhz. (not tried other arduinos - yet). Only the last matrix initialised is driven. The other remains silent. I used a logic analyser and found only the second pin initialised is being driven. At a guess I'd say the code needs some form of parallel processing..

      Delete
    6. Just found this:-
      https://wp.josh.com/2016/05/04/parallel-processing-arduino-style-make-massive-neopixel-displays-with-nanoscale-concurrent-computing/
      It proposes writing to 8 output pins (LED strips) at once. Now if the ALA neopixel library could handle that we could all have even more fun.

      Delete
    7. I have modified AlaLedRgb.cpp to allow the code to drive multiple strips using different pins and to be able to run different animations on different sections of the same strip. You can also control the brightness per section. You can see it in action here:- https://youtu.be/Dfbw7RuKsQ0. The code has been uploaded to github as a public gist (BNNorman / ExtAlaRgb.cpp). Please note I have only tested this using WS2812 - if anyone has other LED strips supported by ALA and can test them then I'd be chuffed.

      Delete
  5. Hi :) Thanks for the help :) Is it possible to animate analog LED-Strips? i am new and i found out that my led-strip is analog

    ReplyDelete
    Replies
    1. Yes you can. First try to implement something like this: https://learn.adafruit.com/rgb-led-strips/usage
      What it works, then you use ALA library to animate it as it was a single led.

      Delete
  6. Excusez-moi, je ne connais pas assez votre langue . Je suis français et je fais du modélisme ferroviaire. Je viens d'essayer votre bibliothèque et j'y vois déjà plein d’application pour éclairer mes maquettes. MERCI BEAUCOUP.
    Excuse me , I do not know enough about your language. I am French and I make the model railway . I just tried your library and I see already full application to illuminate my models . THANK YOU VERY MUCH.(Google traduction)

    ReplyDelete
    Replies
    1. Thank you, I'm happy it helped you for your project.
      Do you have a photo or a video to share?

      Delete
  7. This library blinks all the colors in different ways to our ledstrip. How can you call one animation of the library? We have an 12V/5M addressable ledstrip.

    Hope someone can help me.

    ReplyDelete
    Replies
    1. ALA only support WS2812 RGB LED strips. What kind of strip are you using?

      Delete
  8. Hi, great library with great effects! Is it possible to animate for example a 60LED strip with two different animations? Maybe sparkle LED 1-30 and at the same time "movingbars" for LED 31-60? And an additional question: Is it possible to switch animations by reciving a signal on an input-pin? Thanks for your help! :)

    ReplyDelete
    Replies
    1. It's not possible to animate 2 sections of the same strip. You have to cut it in two strips and drive them separately.
      It is possible to switch animations by reciving a signal on an input-pin. In this sketch i use a button on pin 8 to change animation sequence. You can also directly use setAnimation to switch from one animation to another.


      #include
      #include "AlaLedRgb.h"

      AlaLedRgb rgbStrip;
      Bounce debouncer;

      static AlaColor palCool_[] = { 0x0000FF, 0xFF00FF, 0xFF0000 };
      static AlaPalette palCool = { 3, palCool_ };

      static AlaColor palCool2_[] = { 0xaa8800, 0xdd00dd };
      static AlaPalette palCool2 = { 2, palCool2_ };

      static AlaColor palBubbles_[] = { 0x0000FF, 0x0000FF, 0x0000FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF0000, 0xFFAA00, 0xFF0000 };
      static AlaPalette palBubbles = { 9, palBubbles_ };

      // Rainbow colors with alternating stripes of black
      static AlaColor palCoolStripe_[] =
      {
      0xFF0000, 0x000000, 0xFF00FF, 0x000000, 0xFF0000, 0x000000
      };
      static AlaPalette palCoolStripe = { 5, palCoolStripe_ };

      AlaSeq seq1[] =
      {
      { ALA_FADECOLORSLOOP, 30000, alaPalParty, 60000 },
      { ALA_ENDSEQ, 0, NULL, 0 }
      };
      AlaSeq seq2[] =
      {
      { ALA_FADECOLORSLOOP, 30000, palCool, 60000 },
      { ALA_ENDSEQ, 0, NULL, 0 }
      };

      AlaSeq seq3[] =
      {
      { ALA_MOVINGGRADIENT, 8000, palCool2, 60000 },
      { ALA_ENDSEQ, 0, NULL, 0 }
      };

      int currentAnimation=0;

      void setup()
      {
      delay(1000);
      Serial.begin(115200);

      pinMode(8, INPUT);
      debouncer.attach( 8 );
      debouncer.interval(5);

      rgbStrip.initWS2812(10, 2);

      rgbStrip.setBrightness(0x444444);

      rgbStrip.setAnimation(seq1);
      }

      void loop()
      {
      rgbStrip.runAnimation();

      debouncer.update();

      // Turn on or off the LED as determined by the state :
      if ( debouncer.fell() )
      {
      currentAnimation++;
      }

      if (currentAnimation%3 == 0)
      {
      rgbStrip.setAnimation(seq1);
      }
      if (currentAnimation%3 == 1)
      {
      rgbStrip.setAnimation(seq2);
      }
      if (currentAnimation%3 == 2)
      {
      rgbStrip.setAnimation(seq3);
      }
      }

      Delete
    2. It is now possible to run separate animations on separate sections of the same strip. Please look at my extension to AlaLedRgb.cpp on github published as a gist (BNNorman / ExtAlaRgb.cpp). I'd appreciate your feedback.

      Delete
  9. Hello there. My Arduino board has 6 PWM outputs, and my questions are:

    Is possible to use all those 6 in a single instance, or shall I create two in order to use all my PWM pins?
    Is possible to run two sequence of animations simultaneously?

    ReplyDelete
  10. Hiya! Great job on the library, this made my life sooo much simpler for the costume I'm designing.

    One question, I'll be using this with BuckPucks to drive high power LEDs. The dimmer line on a BuckPuck decreases the brightness as the output goes closer to 5V. Is there any good way to write the code for that, or should I simply use inverted color codes?

    ReplyDelete
  11. Hello! Great library, really. Is it possible to set a different color on each WS2812 LED of a strip using your sequences? I'd like to set my LEDS like this: red, yellow, green and blue.

    ReplyDelete
  12. Hi,

    firstly Thanks for this great project. a humble suggestions that it would be great to have some videos of leds in action, i tried youtube and only found one.

    ReplyDelete
    Replies
    1. Planning to use in version 2 of this project

      http://www.instructables.com/id/Sparrow-My-Assistant/

      Delete
  13. Hey, I'm pretty new to coding. Is there a way to run though an animation only once? THanks

    ReplyDelete
  14. Does your library support the Teensy 3.2 ARM based boards, or only Atmel variants? Looks promising for my project if it supports Teensy ARM Boards.

    ReplyDelete
  15. First thx for sharing your work !

    Does ALA supports Arduino 1.0.5 .

    Because I'm getting this Error when I try to compile:
    SimpleRgbStrip.ino:12:23: warning: AlaLedRgb.h: No such file or directory

    Thx for your answer...

    ReplyDelete
    Replies
    1. I don't know. Can you download the latest client?
      https://www.arduino.cc/en/Main/Software

      Delete
  16. Suddenly I'm getting a 'PULLDOWN' was not declared in this scope for the RGBStripButton example. Please help! What happened?

    ReplyDelete
  17. Still me , you should use Serial Plotter to visualize the input.BR

    ReplyDelete
  18. I tried this on the ESP8266 and having lots of problems. Is there a version that will work on ESP8266?

    ReplyDelete
  19. Hi!

    I'm trying to use ALA with an Attiny85 for my LED RGB Led Strip Driver (https://github.com/jaimelaborda/Attiny85-RGB-LED-Strip-Driver).

    I have try to directly compile an example for the Attiny, and does not compile. Is ALA compatible with Attiny? If not, i can made it compatible or are you using some strange caracteristic of the atmega?

    Thanks! I love ALA! ;)

    ReplyDelete
  20. Hey,
    does ALA support RGBW LEDs as well (such as the SK6812)? The are adressed basically the same way as the WS2812, but have an extra channel for the dedicated white led.

    ReplyDelete