Advertisement
ChipSkylarkk

rainbowCyclePlayer1

Jun 20th, 2013
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.95 KB | None | 0 0
  1. void rainbowCyclePlayer1(uint8_t wait)
  2. {
  3.   int m = 32;
  4.   uint16_t k, j;
  5.  
  6.   //Turns off player 1 LEDs
  7.   digitalWrite(latch2, LOW);
  8.   shiftOut(data2, clock2, MSBFIRST, 255);  
  9.   digitalWrite(latch2, HIGH);
  10.    
  11.   for (j=0; j < 384 * 3; j++) {     // 5 cycles of all 384 colors in the wheel
  12.     for (k=0; k < strip.numPixels(); k++) {
  13.       // tricky math! we use each pixel as a fraction of the full 384-color wheel
  14.       // (thats the i / strip.numPixels() part)
  15.       // Then add in j which makes the colors go around per pixel
  16.       // the % 384 is to make the wheel cycle around
  17.       strip.setPixelColor(k, Wheel( ((k * 384 / strip.numPixels()) + j) % 384) );
  18.     }  
  19.     strip.show();   // write all the pixels out
  20.     delay(wait);
  21.   }
  22.   for(m; m >= 0; m--)
  23.   {
  24.   strip.setPixelColor(m, 0);
  25.   strip.show();
  26.   }
  27.   //Turn on player1 LEDs
  28.   digitalWrite(latch2, LOW);
  29.   shiftOut(data2, clock2, MSBFIRST, 0);  
  30.   digitalWrite(latch2, HIGH);
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement