Checkout this small video to see how the animations look like.
Schematic
Code
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.
The last entry in the array must be ALA_ENDSEQ to close the animation sequence.
#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(5, pins); leds.setAnimation(seq); } void loop() { leds.runAnimation(); }
Hello, i have a problem, I tried to run this code, it compile but the leds does not switch on, I check the connection and everything works fine, could you help me? IDE: 1.6.5 Arduino UNO R3
ReplyDeleteHi this code is not working. please fix it
ReplyDeleteits awesomee! but can you fix it?
ReplyDeletePlease fix the code... really want to try out this program :)
ReplyDeleteHi all.
ReplyDeleteI have fixed the library.
Please download version 2.3 and it should work.
It worked for me :) Thanks for the code
ReplyDelete