Guest User

Untitled

a guest
Nov 6th, 2021
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.40 KB | None | 0 0
  1. #include <FastLED.h>
  2.  
  3. #define Num_Strip1 60
  4. #define Button 7
  5. #define BRIGHTNESS 100
  6.  
  7. CRGB Strip1[Num_Strip1];
  8.  
  9. int Program = 0;
  10. int maxProgram = 2;
  11. int Num = 0;
  12. int Run = 0;
  13. int ButtonDelay = 500;
  14. int Program0Delay = 100;
  15. int Program1Delay = 100;
  16. int Program2Delay = 10;
  17.  
  18. unsigned long ButtonTime = 0;
  19. unsigned long DelayTime = 0;
  20.  
  21. void setup()
  22. {
  23. pinMode(Button, INPUT_PULLUP);
  24. FastLED.addLeds<NEOPIXEL,6>(Strip1, Num_Strip1);
  25. Serial.begin(9600);
  26. FastLED.setBrightness( BRIGHTNESS );
  27. }
  28.  
  29. void loop()
  30. {
  31. if(digitalRead(Button) == LOW && millis() - ButtonTime > ButtonDelay)
  32. {
  33. ButtonTime = millis();
  34. Num = 0;
  35. Run = 0;
  36. if(Program < maxProgram)
  37. {
  38. Program++;
  39. for(int Num = 0; Num < Num_Strip1; Num++)
  40. {
  41. Strip1[Num] = CHSV(255, 255, 0);
  42. }
  43. FastLED.show();
  44. }
  45. else
  46. {
  47. Program = 0;
  48. for(int Num = 0; Num < Num_Strip1; Num++)
  49. {
  50. Strip1[Num] = CHSV(255, 255, 0);
  51. }
  52. FastLED.show();
  53. }
  54. }
  55.  
  56. if(Program == 0 && Run == 0 && millis() - DelayTime >= Program0Delay) {
  57. DelayTime = millis();
  58. Strip1[Num] = CHSV(255, 255, 255);
  59. Num++;
  60. if(Num > Num_Strip1) {
  61. Run = 1;
  62. Num = 0;
  63. Program = 0;
  64. }
  65. FastLED.show();
  66. }
  67.  
  68. if(Program == 0 && Run == 1 && millis() - DelayTime >= Program0Delay) {
  69. DelayTime = millis();
  70. Strip1[Num] = CHSV(155, 255, 255);
  71. Num++;
  72. if(Num > Num_Strip1) {
  73. Run = 2;
  74. Num = 0;
  75. Program = 0;
  76. }
  77. FastLED.show();
  78. }
  79.  
  80. if(Program == 0 && Run == 2 && millis() - DelayTime >= Program0Delay) {
  81. DelayTime = millis();
  82. Strip1[Num] = CHSV(100, 255, 255);
  83. Num++;
  84. if(Num > Num_Strip1) {
  85. Run = 3;
  86. Num = Num_Strip1 - 1;
  87. Program = 0;
  88. }
  89. FastLED.show();
  90. }
  91.  
  92. if(Program == 0 && Run == 3 && millis() - DelayTime >= Program0Delay) {
  93. DelayTime = millis();
  94. Strip1[Num] = CHSV(255, 255, 255);
  95. Num--;
  96. if(Num < 0) {
  97. Run = 4;
  98. Num = Num_Strip1 - 1;
  99. Program = 0;
  100. }
  101. FastLED.show();
  102. }
  103.  
  104. if(Program == 0 && Run == 4 && millis() - DelayTime >= Program0Delay) {
  105. DelayTime = millis();
  106. Strip1[Num] = CHSV(155, 255, 255);
  107. Num--;
  108. if(Num < 0) {
  109. Run = 5;
  110. Num = Num_Strip1 - 1;
  111. Program = 0;
  112. }
  113. FastLED.show();
  114. }
  115.  
  116. if(Program == 0 && Run == 5 && millis() - DelayTime >= Program0Delay) {
  117. DelayTime = millis();
  118. Strip1[Num] = CHSV(100, 255, 255);
  119. Num--;
  120. if(Num < 0) {
  121. Run = 0;
  122. Num = 0;
  123. Program = 0;
  124. }
  125. FastLED.show();
  126. }
  127.  
  128. if(Program == 1 && Run == 0 && millis() - DelayTime >= Program1Delay) {
  129. DelayTime = millis();
  130. Strip1[Num] = CHSV(255, 255, 255);
  131. Num++;
  132. Strip1[Num] = CHSV(155, 255, 255);
  133. if(Num >= Num_Strip1 - 1) {
  134. Run = 1;
  135. Program = 1;
  136. }
  137. FastLED.show();
  138. }
  139.  
  140. if(Program == 1 && Run == 1 && millis() - DelayTime >= Program1Delay) {
  141. DelayTime = millis();
  142. Strip1[Num] = CHSV(255, 255, 255);
  143. Num--;
  144. Strip1[Num] = CHSV(155, 255, 255);
  145. if(Num <= 0) {
  146. Run = 0;
  147. Program = 1;
  148. }
  149. FastLED.show();
  150. }
  151.  
  152. if(Program == 2 && millis() - DelayTime >= Program2Delay) {
  153. DelayTime = millis();
  154. for(; Num <= Num_Strip1; Num++) {
  155. Strip1[Num] = CHSV(random(0, 255), 255, 255);
  156. }
  157. FastLED.show();
  158. Num = 0;
  159. Program = 2;
  160. }
  161. }
Advertisement
Add Comment
Please, Sign In to add comment