Guest User

Untitled

a guest
Jun 14th, 2017
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.73 KB | None | 0 0
  1. void spiral2() {
  2.   static uint8_t stripIndex = 0;
  3.   static uint8_t dotIndex = 0;
  4.  
  5.   // first, dim all LEDs, every time
  6.   for (int x = 0; x < NUM_STRIPS; x++) {
  7.     for (int i = 0; i < NUM_LEDS_PER_STRIP; i++) {
  8.       leds [x][i].fadeToBlackBy(64);
  9.     }
  10.   }
  11.  
  12.   // then, once per X milliseconds, light up the next LED
  13.   EVERY_N_MILLISECONDS(1000) {
  14.     leds[stripIndex][dotIndex] = CHSV( gHue + random8(64), 200, 255);
  15.  
  16.     // move to the next strip
  17.     stripIndex++;
  18.  
  19.     // wrap back to the first strip
  20.     if (stripIndex >= NUM_STRIPS) {
  21.       stripIndex = 0;
  22.     }
  23.  
  24.     // move to the next LED
  25.     dotIndex++;
  26.  
  27.     // wrap back to the first LED
  28.     if (dotIndex >= NUM_LEDS_PER_STRIP) {
  29.       dotIndex = 0;
  30.     }
  31.   }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment