Advertisement
KelvinMead

WS2811 / Fast_Spi2 / BottomToTop

Aug 24th, 2013
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.02 KB | None | 0 0
  1. /* rows of leds moving up, very fast
  2. /* Kelvin Mead Aug/14
  3. /* WS2811 / Fast_SPI2
  4. */
  5.  
  6. #include <FastSPI_LED2.h>
  7.  
  8. #define NUM_LEDS 320
  9.  
  10. CRGB leds[NUM_LEDS];
  11.  
  12. long previousMillis = 0; // will store last time LED was updated
  13. long interval = 100; // interval at which to blink (milliseconds)
  14. int bright = 255; // easy adjustable brightness
  15. const int ledsperstrip = 32;
  16.  
  17. // i know there's better ways of doing this, but this works for me at the moment.
  18. int allleds[320] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
  19. 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32,
  20. 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
  21. 127, 126, 125, 124, 123, 122, 121, 120, 119, 118, 117, 116, 115, 114, 113, 112, 111, 110, 109, 108, 107, 106, 105, 104, 103, 102, 101, 100, 99, 98, 97, 96,
  22. 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159,
  23. 191, 190, 189, 188, 187, 186, 185, 184, 183, 182, 181, 180, 179, 178, 177, 176, 175, 174, 173, 172, 171, 170, 169, 168, 167, 166, 165, 164, 163, 162, 161, 160,
  24. 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223,
  25. 255, 254, 253, 252, 251, 250, 249, 248, 247, 246, 245, 244, 243, 242, 241, 240, 239, 238, 237, 236, 235, 234, 233, 232, 231, 230, 229, 228, 227, 226, 225, 224,
  26. 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287,
  27. 319, 318, 317, 316, 315, 314, 313, 312, 311, 310, 309, 308, 307, 306, 305, 304, 303, 302, 301, 300, 299, 298, 297, 296, 295, 294, 293, 292, 291, 290, 289, 288,};
  28.  
  29.  
  30. void setup() {
  31. delay(2000);
  32. LEDS.setBrightness(bright);
  33. LEDS.addLeds<WS2811, 13>(leds, NUM_LEDS);
  34. }
  35.  
  36.  
  37.  
  38. void loop() {
  39.  
  40. unsigned long currentMillis = millis();
  41. if(currentMillis - previousMillis > interval) {
  42. previousMillis = currentMillis;
  43.  
  44. //put programs in here to be controlled by the delay time
  45. // program name (r, g, b, speed)
  46. bottomtotop2(51, 102, 153, 50);
  47.  
  48. LEDS.setBrightness(bright);
  49. } // end timed loop
  50. } // end void loop
  51.  
  52. void bottomtotop2(int cred, int cblu, int cgrn, int cinterval) {
  53. interval = cinterval;
  54. memset(leds, 0, NUM_LEDS * sizeof(struct CRGB));
  55. //intergrated for loops slow this down
  56. for(int j = 0; j < 31; j++) {
  57. leds[allleds[j]].setRGB(cred, cblu, cgrn);
  58. leds[allleds[j+ledsperstrip]].setRGB(cred, cblu, cgrn);
  59. leds[allleds[j+ledsperstrip*2]].setRGB(cred, cblu, cgrn);
  60. leds[allleds[j+ledsperstrip*3]].setRGB(cred, cblu, cgrn);
  61. leds[allleds[j+ledsperstrip*4]].setRGB(cred, cblu, cgrn);
  62. leds[allleds[j+ledsperstrip*5]].setRGB(cred, cblu, cgrn);
  63. leds[allleds[j+ledsperstrip*6]].setRGB(cred, cblu, cgrn);
  64. leds[allleds[j+ledsperstrip*7]].setRGB(cred, cblu, cgrn);
  65. leds[allleds[j+ledsperstrip*8]].setRGB(cred, cblu, cgrn);
  66. leds[allleds[j+ledsperstrip*9]].setRGB(cred, cblu, cgrn);
  67. leds[allleds[j-2]].setRGB(0,0,0);
  68. leds[allleds[j-4+ledsperstrip]].setRGB(0,0,0);
  69. leds[allleds[j-4+ledsperstrip*2]].setRGB(0,0,0);
  70. leds[allleds[j-4+ledsperstrip*3]].setRGB(0,0,0);
  71. leds[allleds[j-4+ledsperstrip*4]].setRGB(0,0,0);
  72. leds[allleds[j-4+ledsperstrip*5]].setRGB(0,0,0);
  73. leds[allleds[j-4+ledsperstrip*6]].setRGB(0,0,0);
  74. leds[allleds[j-4+ledsperstrip*7]].setRGB(0,0,0);
  75. leds[allleds[j-4+ledsperstrip*8]].setRGB(0,0,0);
  76. leds[allleds[j-4+ledsperstrip*9]].setRGB(0,0,0);
  77. LEDS.show();
  78. }
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement