Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // select animations with a pot (Code snipplet)
- #define NUMVIZ 7 // number of selectable options (0..6)
- #define POT_INPUT A3
- int readpot()
- {
- return analogRead(POT_INPUT);
- }
- in loop:
- int potval = readpot();
- byte vizval = potval / (1024/NUMVIZ); // get a viz number based on the pot position
- // Serial.println (vizval);
- bool newviz = 0;
- if (vizval != lastvizval) newviz = 1; // if it's changed, trigger the initialisations
- switch (vizval)
- {
- case 0:
- if (newviz) fill_solid( &(leds[0]), NUM_LEDS, CRGB( 0,0,0) ); // switch strip to black
- // animation here
- break;
- case 1:
- if (newviz) fill_solid( &(leds[0]), NUM_LEDS, CRGB( 0,0,0) );
- // animation here
- break;
- case 2:
- if (newviz) fill_solid( &(leds[0]), NUM_LEDS, CRGB( 0,0,0) );
- // animation here
- break;
- case 3:
- if (newviz) fill_solid( &(leds[0]), NUM_LEDS, CRGB( 0,0,0) );
- // animation here
- break;
- case 4:
- if (newviz) fill_solid( &(leds[0]), NUM_LEDS, CRGB( 0,0,0) );
- // animation here
- break;
- case 5:
- if (newviz) initblobs();
- // animation here
- break;
- case 6:
- if (newviz) fill_solid( &(leds[0]), NUM_LEDS, CRGB( 0,0,0) );
- // animation here
- break;
- }
- lastvizval = vizval;
- newviz = 0;
- FastLED.show(); // display this frame
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement