Guest User

Switching_patterns_with_pushbutton

a guest
Jan 25th, 2017
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. //Switching patterns using switch case and a pushbutton.
  2. //Big thanks to Sergio Martinez for explaning switch case
  3. //to me and helping me write the code!
  4.  
  5.  
  6. #include "FastLED.h"
  7. #include "Buttons.h"
  8. #include "Patterns.h"
  9.  
  10. #define DATA_PIN 0
  11. #define DC_OFFSET 0
  12. #define SAMPLES 60
  13. #define NUMBER_OF_MODES 6
  14. #define LED_TYPE WS2812B
  15. #define COLOR_ORDER GRB
  16.  
  17.  
  18. #define BRIGHTNESS 85
  19. #define FRAMES_PER_SECOND 120
  20.  
  21.  
  22.  
  23. void setup(){
  24. pinMode(BUTTON_LEAD, INPUT_PULLUP);
  25. FastLED.addLeds<LED_TYPE, DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
  26. FastLED.setBrightness(BRIGHTNESS);
  27. }
  28.  
  29.  
  30. void loop() {
  31.  
  32. switch (mode) {
  33. case 1:
  34. sinelon();
  35. break;
  36.  
  37. case 2:
  38. rainbow();
  39. break;
  40.  
  41. case 3:
  42. rainbowWithGlitter();
  43. break;
  44.  
  45. case 4:
  46. juggle();
  47. break;
  48.  
  49. case 5:
  50. bpm();
  51. break;
  52.  
  53. case 6:
  54. confetti();
  55. break;
  56.  
  57. case 7:
  58. random_burst();
  59. break;
  60.  
  61. case 8:
  62. pride();
  63. break;
  64.  
  65. default:
  66. mode = 1;
  67. break;
  68. }
  69. FastLED.show();
  70. EVERY_N_MILLISECONDS( 20 ) { gHue++; }
  71. }
Advertisement
Add Comment
Please, Sign In to add comment