Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //////////////////////////////
- // LED LIGHT SHOW PRESETS //
- //////////////////////////////
- int showType = 0;
- void startShow(int i) {
- switch(i){
- case 0: colorWipe(strip.Color(0, 0, 0), 50); // Black/off
- break;
- case 1: colorWipe(strip.Color(255, 0, 0), 50); // Red
- break;
- case 2: colorWipe(strip.Color(0, 255, 0), 50); // Green
- break;
- case 3: colorWipe(strip.Color(0, 0, 255), 50); // Blue
- break;
- case 4: theaterChase(strip.Color(127, 127, 127), 50); // White
- break;
- case 5: theaterChase(strip.Color(127, 0, 0), 50); // Red
- break;
- case 6: theaterChase(strip.Color( 0, 0, 127), 50); // Blue
- break;
- case 7: rainbow(20);
- break;
- case 8: rainbowCycle(20);
- break;
- case 9: theaterChaseRainbow(50);
- break;
- }
- }
- uint32_t Wheel(byte WheelPos) {
- WheelPos = 255 - WheelPos;
- if(WheelPos < 85) {
- return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
- }
- if(WheelPos < 170) {
- WheelPos -= 85;
- return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
- }
- WheelPos -= 170;
- return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
- }
- void colorWipe(uint32_t c, uint8_t wait) {
- for(uint16_t i=0; i<strip.numPixels(); i++) {
- strip.setPixelColor(i, c);
- strip.show();
- delay(wait);
- }
- }
- void rainbow(uint8_t wait) {
- uint16_t i, j;
- for(j=0; j<256; j++) {
- for(i=0; i<strip.numPixels(); i++) {
- strip.setPixelColor(i, Wheel((i+j) & 255));
- }
- strip.show();
- delay(wait);
- }
- }
- void rainbowCycle(uint8_t wait) {
- uint16_t i, j;
- for(j=0; j<256*5; j++) { // 5 cycles of all colors on wheel
- for(i=0; i< strip.numPixels(); i++) {
- strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
- }
- strip.show();
- delay(wait);
- }
- }
- void theaterChase(uint32_t c, uint8_t wait) {
- for (int j=0; j<10; j++) { //do 10 cycles of chasing
- for (int q=0; q < 3; q++) {
- for (int i=0; i < strip.numPixels(); i=i+3) {
- strip.setPixelColor(i+q, c); //turn every third pixel on
- }
- strip.show();
- delay(wait);
- for (int i=0; i < strip.numPixels(); i=i+3) {
- strip.setPixelColor(i+q, 0); //turn every third pixel off
- }
- }
- }
- }
- void theaterChaseRainbow(uint8_t wait) {
- for (int j=0; j < 256; j++) { // cycle all 256 colors in the wheel
- for (int q=0; q < 3; q++) {
- for (int i=0; i < strip.numPixels(); i=i+3) {
- strip.setPixelColor(i+q, Wheel( (i+j) % 255)); //turn every third pixel on
- }
- strip.show();
- delay(wait);
- for (int i=0; i < strip.numPixels(); i=i+3) {
- strip.setPixelColor(i+q, 0); //turn every third pixel off
- }
- }
- }
- }
- // BUTTON CODE
- void bt10PushCallback(void *ptr)
- {
- if (showType < 9) {
- showType++;
- if (showType > 9)
- showType=0;
- startShow(showType);
- }
- }
Add Comment
Please, Sign In to add comment