ALA Example - SimpleLed

This is the simplest example for the ALA library. It is showing how to make a simple fading animation effect using a LED driven by an Arduino PWM output.

The sketch is very simple. Only three lines of code.

#include <AlaLed.h>

AlaLed alaLed;

void setup()
{
  // initialize the led attached to pin 11 with PWM driver
  alaLed.initPWM(11);
  
  // set a fading animation with a duration of 2 seconds
  alaLed.setAnimation(ALA_FADEIN, 2000);
}

void loop()
{
  // run the animation
  alaLed.runAnimation();
}

The circuit is the same used in the Blink example but the LED must be connected to pin 11.

The ALA library provides many nice animations. Try changing the animation type with ALA_BLINK or ALA_GLOW.

You are now ready to move to the MultiLedSequence example.

4 comments:

  1. This is so awesomeeeee!
    How should I proceed if I want to animated two leds independently?
    Thank you so much for this.

    ReplyDelete
  2. found out how in further reading your posts :) also found info about how to change animation in a comment you responded, would switching an animation be done smoothly? for example a led is fading in and the animation switched to, calls it to fade out, would the led fade starting exactly where the current animation has the brightness and then fades out or it will abruptly lit and then fade out? Thanks a Zillion!

    ReplyDelete
  3. My first post. First play with Nano and after a lot of time I managed to get the Blink program working. I have changed code to alter the blink rate.. Wow ! :) Now looking for another led project to download but this on did not work, failed to upload. Can anyone suggest my next nano led based program to run please ?

    ReplyDelete
  4. Where can I get the information about initPWM, setanimation functions? I mean about the arguments of those functions..

    ReplyDelete

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