Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Switching patterns using switch case and a pushbutton.
- //Big thanks to Sergio Martinez for explaning switch case
- //to me and helping me write the code!
- #include "FastLED.h"
- #include "Buttons.h"
- #include "Patterns.h"
- #define DATA_PIN 0
- #define DC_OFFSET 0
- #define SAMPLES 60
- #define NUMBER_OF_MODES 6
- #define LED_TYPE WS2812B
- #define COLOR_ORDER GRB
- #define BRIGHTNESS 85
- #define FRAMES_PER_SECOND 120
- void setup(){
- pinMode(BUTTON_LEAD, INPUT_PULLUP);
- FastLED.addLeds<LED_TYPE, DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
- FastLED.setBrightness(BRIGHTNESS);
- }
- void loop() {
- switch (mode) {
- case 1:
- sinelon();
- break;
- case 2:
- rainbow();
- break;
- case 3:
- rainbowWithGlitter();
- break;
- case 4:
- juggle();
- break;
- case 5:
- bpm();
- break;
- case 6:
- confetti();
- break;
- case 7:
- random_burst();
- break;
- case 8:
- pride();
- break;
- default:
- mode = 1;
- break;
- }
- FastLED.show();
- EVERY_N_MILLISECONDS( 20 ) { gHue++; }
- }
Advertisement
Add Comment
Please, Sign In to add comment