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)
  • SimpleRgbStrip - A simple animation with an RGB LED strip.
  • RgbStripSequence - Animation sequence for an RGB LED strip.
  • RgbStripSerial - This is a playground for the ALA library that allows to control animations using AT serial commands..
TLC5940
Advanced


49 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
    2. I'm curious how one might go about hacking the "chip_includes.h" file to support the Arduino MKR Zero board. I've been working on a project and am now on the home stretch, but using this library ran me into SRAM capacity issues on the Arduino Nano, so, now, after upgrading to the MKR Zero, I'm getting a compilation error "Unknown Chip!". Is there any easy way to side-step this for the ATMEL SAMD21?

      Delete
    3. Logged an issue within GitHub on this topic ... happy to take the convo over to the repo ==> https://github.com/bportaluri/ALA/issues/22

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

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

    ReplyDelete
  18. 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
    Replies
    1. Please Replay Bruno! we're stuck !!!!!!!

      Delete
    2. NO it seems it's not compatible. Look at chip_includes.h inside the library for more infos.

      Delete
  19. 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
  20. Hello,
    your implementation about NON BLOCKING patterns is one of a kind.
    Now it is very easy to switch between them with no worries if a delay is in the middle.
    I am working on a project which has rf implementation for synchronizing led strips wirelessy.
    One node is server for triggering patterns and the the others have the same client configuration. Nrf24 with arduino Nano.
    I've managed to make it work in an hour!!
    the code for Trigger is :

    ----------------------------------------------------------------------------------------
    #include "nRF24L01.h"
    #include "RF24.h"
    #include "SPI.h"
    int SentMessage[1] = {000};
    RF24 radio(9,10);
    const uint64_t pipe = 0xE6E6E6E6E6E6;

    void setup(){
    radio.begin();
    radio.openWritingPipe(pipe);
    }

    void loop(){

    SentMessage[0] = 1;
    radio.write(SentMessage, 1);
    delay(8000);
    SentMessage[0] = 2;
    radio.write(SentMessage, 1);
    delay(9000);
    SentMessage[0] = 3;
    radio.write(SentMessage, 1);
    delay(9000);
    SentMessage[0] = 4;
    radio.write(SentMessage, 1);
    delay(8000);
    SentMessage[0] = 5;
    radio.write(SentMessage, 1);
    delay(8000);
    SentMessage[0] = 6;
    radio.write(SentMessage, 1);
    delay(8000);
    SentMessage[0] = 7;
    radio.write(SentMessage, 1);
    delay(8000);
    SentMessage[0] = 8;
    radio.write(SentMessage, 1);
    delay(8000);
    SentMessage[0] = 9;
    radio.write(SentMessage, 1);
    delay(8000);
    SentMessage[0] = 10;
    radio.write(SentMessage, 1);
    delay(8000);
    }
    --------------------------------------------------------------------------------------------------
    and for the receivers is :
    --------------------------------------------------------------------------------------------------
    #include "nRF24L01.h"
    #include "RF24.h"
    #include "SPI.h"
    #include
    int ReceivedMessage[1] = {000};
    RF24 radio(9,10);
    const uint64_t pipe = 0xE6E6E6E6E6E6;
    AlaLedRgb rgbStrip;

    void setup(void){

    radio.begin();
    radio.openReadingPipe(1,pipe);
    radio.startListening();
    rgbStrip.initWS2812(40, 8);
    rgbStrip.setBrightness(0xffffff);
    }

    void loop(){

    while (radio.available())
    {
    radio.read(ReceivedMessage, 1);

    if (ReceivedMessage[0] == 1)
    {rgbStrip.setAnimation(ALA_FIRE,1000,alaPalFire);}
    if (ReceivedMessage[0] == 2)
    {rgbStrip.setAnimation(ALA_BUBBLES,1000,alaPalParty);}
    if (ReceivedMessage[0] == 3)
    {rgbStrip.setAnimation(ALA_FADECOLORS,3000,alaPalParty);}
    if (ReceivedMessage[0] == 4)
    {rgbStrip.setAnimation(ALA_MOVINGBARS,200,alaPalRgb);}
    if (ReceivedMessage[0] == 5)
    {rgbStrip.setAnimation(ALA_BOUNCINGBALLS,1000,alaPalRgb);}
    if (ReceivedMessage[0] == 6)
    {rgbStrip.setAnimation(ALA_GLOW,1000,alaPalParty);}
    if (ReceivedMessage[0] == 7)
    {rgbStrip.setAnimation(ALA_LARSONSCANNER,1000,alaPalRgb);}
    if (ReceivedMessage[0] == 8)
    {rgbStrip.setAnimation(ALA_SPARKLE2, 1000,alaPalRgb);}
    if (ReceivedMessage[0] == 9)
    {rgbStrip.setAnimation(ALA_CYCLECOLORS, 1000,alaPalRgb);}
    if (ReceivedMessage[0] == 10)
    {rgbStrip.setAnimation(ALA_MOVINGGRADIENT, 1000,alaPalRgb);}
    if (ReceivedMessage[0] == 11)
    {rgbStrip.setAnimation(ALA_BLINKALT, 500,alaPalRgb);}

    }
    rgbStrip.runAnimation();
    }
    ------------------------------------------------------------------------------------------------

    I want to ask you if you can implement fill collors,unfill colors and your barshift you have for simple leds to alaledrgb?

    thanks in advance

    Niko

    ReplyDelete
  21. Ich versuche die lib auf einer Nodemcu zu betreiben. leider meckert er immer das avr/io.h fehlt. nehme ich ein anderes board klappt es

    ReplyDelete
  22. Could you write the library to use the PCA9685 IC please?

    https://github.com/NachtRaveVL/PCA9685-Arduino

    ReplyDelete
  23. Hi,
    Do you have a version of this library for use with ESP8266?

    ReplyDelete
  24. There's a small bug in bubbles. On line 786, an LED is selected using the mapfloat function. Under certain conditions, pxPos[i] can be > 1.0, resulting in an array overflow on line 788. This causes the sketch to crash.

    I added if (p < numLeds) to condition the assignment. It fixes the crash and seems to have no visible impact on the animation.

    To note: I have a strip of 112 LEDs and am calling { ALA_BUBBLES, 1000, 6000, alaPalRainbow }

    ReplyDelete
    Replies
    1. Thanks Michael, it fixed the crash I was experiencing. The line number is currently 799.

      Delete
  25. Hey. Great library and work!
    Would you know if your library should work with ESP32? I'm getting library conflict errors, not sure if that's because of Arduino IDE issues or the library.
    Cheers

    ReplyDelete
  26. Nice post. It is really interesting. Thanks for sharing the post!
    Thanks for sharing.This is nice and helpful post.Ceiling lights

    ReplyDelete
  27. Thanks for sharing information, best information provided by you. I have shared this details to 5 friends. Keep posting!

    ReplyDelete
  28. Hi, please assist how to get this ALA web work with 600 leds?, I test with setup 60 leds and its working!
    When I change led value to 600 nothing light up???
    Why? Any clue? I test to code my Arduino with NeoPixel for 600leds with no issue, so Arduino is working correct!, there must be something in the ALA code thats cause this light up issue for 600leds, please help to solve it.

    ReplyDelete

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