Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "FastSPI_LED2.h"
- #define NUM_LEDS 16
- #define DATA_PIN 1
- CRGB leds[NUM_LEDS];
- // LED FX VARS
- int ihue = 0;
- void setup() {
- FastLED.addLeds<WS2811, DATA_PIN, GRB>(leds, NUM_LEDS);
- randomSeed(analogRead(0));
- }
- void loop() {
- flame(300);
- rainbow_loop(5,30,128);
- int fhue = random(255);
- flicker(fhue,255,300);
- simpleWave(0.03,39,10, fhue);
- }
- void simpleWave(float rate,int cycles,int wait, int hue) {
- float pos = 0.0;
- for(int x=0; x<(NUM_LEDS*cycles); x++) {
- pos = pos+rate;
- for (int i=0; i<NUM_LEDS;i++) {
- float level = sin(i+pos) * 127 + 128;
- leds[i] = CHSV(hue,255,level);
- }
- FastLED.show();
- delay(wait);
- }
- }
- void pacman(int reps, int wait) {
- // pacman inspired animation - start yellow, moves towards power-pellet at top
- }
- void flicker(int thishue, int thissat, int reps) { //-m9-FLICKER EFFECT
- for (int q = 0; q<=reps; q++) {
- int random_bright = random(0,255);
- int random_delay = random(10,100);
- int random_bool = random(0,random_bright);
- if (random_bool < 10) {
- for(int i = 0 ; i < NUM_LEDS; i++ ) {
- leds[i] = CHSV(thishue, thissat, random_bright);
- }
- FastLED.show();
- delay(random_delay);
- }
- }
- }
- void rainbow_loop(int istep, int idelay, int reps) {
- for (int q=0;q<reps;q++) {
- ihue = ihue+istep;
- fill_rainbow(&leds[0],NUM_LEDS,ihue);
- FastLED.show();
- delay(idelay);
- }
- }
- void flame(int reps) {
- for(int q=0; q<reps; q++){
- float hmin = 0.1; float hmax = 45.0;
- float hdif = hmax-hmin;
- int randtemp = random(0,3);
- int rtop = random(10,NUM_LEDS);
- float hinc = (hdif/float(rtop))+randtemp;
- int ihue = hmin;
- fill_solid(&leds[0],NUM_LEDS,CHSV(0,0,0));
- for(int i = 0; i < rtop; i++ ) {
- ihue = ihue + hinc;
- leds[i] = CHSV(ihue, 255, 255);
- leds[rtop].r = 255; leds[rtop].g = 255; leds[rtop].b = 255;
- }
- FastLED.show();
- int idelay = random(20,50);
- delay(idelay);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment