Advertisement
Guest User

Untitled

a guest
May 26th, 2019
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.20 KB | None | 0 0
  1. #include <FastLED.h>
  2.  
  3. #define NUM_LEDS 144
  4. #define DATA_PIN 6
  5. #define TICK_DELAY_MILLISECONDS 20
  6.  
  7. //define some color names
  8. CRGB pink = CRGB(255,20,140);
  9. CRGB yellow = CRGB(255,218,0);
  10. CRGB blue = CRGB(5,174,255);
  11. CRGB gflux1 = CRGB(246,118,149);
  12. CRGB gflux2 = CRGB(242,161,184);
  13. CRGB gflux3 = CRGB(206,204,204);
  14. CRGB gflux4 = CRGB(121,223,246);
  15. CRGB gflux5 = CRGB(255,244,138);
  16. CRGB white = CRGB(255,255,255);
  17. CRGB lgray = CRGB(100,100,100);
  18. CRGB dgray = CRGB(50,50,50);
  19. CRGB black = CRGB(25,25,25);
  20. CRGB brown = CRGB(60,60,30);
  21. CRGB off = CRGB(0,0,0);
  22.  
  23. CRGB red = CRGB(255,0,0);
  24. CRGB orange = CRGB(255, 140, 0);
  25. CRGB green = CRGB(0,255,50);
  26. CRGB purple = CRGB(255,0,255);
  27.  
  28. //define your pattern
  29. #define num_segments 68
  30. #define segmentLength 4
  31.  
  32. static CRGB segments[num_segments] ={
  33. blue,
  34. blue,
  35. pink,
  36. pink,
  37. white,
  38. white,
  39. pink,
  40. pink,
  41. blue,
  42. blue,
  43.  
  44. off,
  45. off,
  46. off,
  47.  
  48. pink,
  49. pink,
  50. pink,
  51. yellow,
  52. yellow,
  53. yellow,
  54. blue,
  55. blue,
  56. blue,
  57.  
  58. off,
  59. off,
  60. off,
  61.  
  62. pink,
  63. pink,
  64. gflux3,
  65. gflux3,
  66. blue,
  67. blue,
  68. yellow,
  69. yellow,
  70.  
  71. off,
  72. off,
  73. off,
  74.  
  75. black,
  76. brown,
  77. red,
  78. orange,
  79. yellow,
  80. green,
  81. blue,
  82. purple,
  83.  
  84. off,
  85. off,
  86. off,
  87.  
  88. dgray,
  89. lgray,
  90. pink,
  91. white,
  92. pink,
  93. lgray,
  94. dgray,
  95.  
  96. off,
  97. off,
  98. off,
  99.  
  100. yellow,
  101. yellow,
  102. white,
  103. white,
  104. purple,
  105. purple,
  106. black,
  107. black,
  108.  
  109. off,
  110. off,
  111. off
  112. };
  113.  
  114. int cur_seg_num = 0;
  115. int cur_seg_prog = 0;
  116.  
  117. CRGB led_active[NUM_LEDS];
  118.  
  119. void setup() {
  120. FastLED.addLeds<NEOPIXEL, DATA_PIN>(led_active, NUM_LEDS);
  121. FastLED.setBrightness(60);
  122. }
  123.  
  124. void loop() {
  125. digitalWrite(13,(cur_seg_num == 0? LOW:HIGH));
  126.  
  127. for (int i = NUM_LEDS - 1; i > 0; i--) {
  128. //push each value forward by one
  129. led_active[i] = led_active[i-1];
  130. }
  131.  
  132. //set first led to new color, and incriment the variable we're copyign from
  133.  
  134. led_active[0] = segments[cur_seg_num];
  135. if(++cur_seg_prog >= segmentLength){
  136. cur_seg_num++;
  137. cur_seg_num %= num_segments;
  138. cur_seg_prog = 0;
  139. }
  140. // led_active[0] = brown;
  141.  
  142. //update the strand and wait
  143. FastLED.show();
  144. delay(TICK_DELAY_MILLISECONDS);
  145. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement