Checkout this small video to see how the animations look like.
Circuit
The circuit is really simple. Just five red LEDs connected to five analog output pins of the Arduino and five 220 Ohm resistors.Code
You have to download and install the ALA library from here first.#include <AlaLed.h> AlaLed leds; byte pins[] = { 5, 6, 9, 10, 11 }; AlaSeq seq[] = { { ALA_FADEIN, 1000, 1000 }, { ALA_ON, 1000, 1000 }, { ALA_FADEOUT, 1000, 1000 }, { ALA_BARSHIFTRIGHT, 1000, 1000 }, { ALA_BARSHIFTLEFT, 1000, 1000 }, { ALA_OFF, 1000, 1000 }, { ALA_PIXELSHIFTRIGHT, 700, 1400 }, { ALA_PIXELSHIFTLEFT, 700, 1400 }, { ALA_BLINKALT, 500, 3000 }, { ALA_PIXELSMOOTHSHIFTRIGHT, 1000, 4000 }, { ALA_PIXELSMOOTHSHIFTLEFT, 1000, 4000 }, { ALA_FADEINOUT, 1000, 4000 }, { ALA_COMET, 1000, 4000 }, { ALA_GLOW, 1000, 4000 }, { ALA_STROBO, 200, 4000 }, { ALA_ENDSEQ, 0, 0 } }; void setup() { leds.initPWM(3, pins); leds.setAnimation(seq); } void loop() { leds.runAnimation(); }
I have designed the ALA library with simplicity in mind. You just need to initialize the AlaLed object in the setup function passing the number of LEDs you want to drive. Then you call the runAnimation method passing an array of triplets to describe the desired animation sequence. Finally you have to call the runAnimation method in the loop function to animate your LEDs.
The tricky part is the AlaSeq structure that is made by 3 fields:
- A numeric code identifying the desired animation. Valid codes are listed in the Ala.h header file.
- The animation loop duration in milliseconds.
- The animation total duration in milliseconds.
Wow, cool post. I'd like to write like this too - taking time and real hard work to make a great article... but I put things off too much and never seem to get started. Thanks though. https://krmlight.com/2000-lumen-led-bulb/
ReplyDelete