24framevideo

BLINKENLICHTEN_v1

Jun 4th, 2014
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 3.19 KB | None | 0 0
  1. #include <Adafruit_NeoPixel.h>
  2.  
  3. #define LED_COUNT 240
  4. #define PIN 8
  5.  
  6.  
  7. // Parameter 1 = number of pixels in strip
  8. // Parameter 2 = pin number (most are valid)
  9. // Parameter 3 = pixel type flags, add together as needed:
  10. //   NEO_KHZ800  800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
  11. //   NEO_KHZ400  400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
  12. //   NEO_GRB     Pixels are wired for GRB bitstream (most NeoPixel products)
  13. //   NEO_RGB     Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
  14. Adafruit_NeoPixel strip = Adafruit_NeoPixel(LED_COUNT, PIN, NEO_GRB + NEO_KHZ800);
  15. int potPin = 2;    // select the input pin for the potentiometer
  16. int val = 0;       // variable to store the value coming from the sensor
  17.  
  18. void setup() {
  19.  // strip.setBrightness(50);//THIS WORKS!!!
  20.   strip.begin();
  21.   strip.show(); // Initialize all pixels to 'off'
  22.  
  23. }
  24.  
  25. void modeFireplace(){
  26.     uint8_t iRandom = 0;
  27.     for(int iRow = 0; iRow<8; iRow++){//not sure what this number do I think it changes initial groups/groupings
  28.  
  29.         for(int iCol = 0; iCol<8; iCol++){
  30.   //changing the icol # changings groupings
  31.                 for(int iBlank = 0; iBlank < strip.numPixels(); iBlank++){strip.setPixelColor(iRow+(iCol*10), 0,0,0);}
  32.        //expand teh number after icol* as you add pixels        
  33.             iRandom = random(1,200);//note random 1-100
  34. //colors here are listed R,G,B
  35. //changing the number after iRandom > results in blink rate change
  36.             if (iRandom > 195){strip.setPixelColor(iCol, 0, random (150,255),0);}//randomn flash green 1-5
  37.             if (iRandom > 197){strip.setPixelColor(5+iCol,  random(150,255), 0,0);}//random flash red 6-8
  38.             if (iRandom > 195){strip.setPixelColor(8+iCol, 0, 0, random(150,255));}//random flash blue 9-15
  39.             if (iRandom > 193){strip.setPixelColor(13+iCol, random(100,255), 0, 0);}//13-17 red
  40.             if (iRandom > 94){strip.setPixelColor(16+iCol, 0, 0,  random(100,255));}//18-21 blue
  41.             if (iRandom > 95){strip.setPixelColor(22+iCol, 0, random (0,255),0);}//22-26
  42.             if (iRandom > 97){strip.setPixelColor(27+iCol,  random(10,255), 0,0);}//27-31
  43.             if (iRandom > 85){strip.setPixelColor(32+iCol, 0, 0, random(15,255));}//32-36
  44.             if (iRandom > 93){strip.setPixelColor(37+iCol, random(10,255), 0, 0);}//37-41
  45.             if (iRandom > 74){strip.setPixelColor(42+iCol, 0, 0,  random(100,255));}//42-46
  46.                         if (iRandom > 125){strip.setPixelColor(47+iCol, 0, random (150,255),0);}//randomn flash green 1-5
  47.             if (iRandom > 170){strip.setPixelColor(52+iCol,  random(150,255), 0,0);}//random flash red 6-8
  48.             if (iRandom > 150){strip.setPixelColor(57+iCol, 0, 0, random(150,255));}//random flash blue 9-15
  49.             if (iRandom > 183){strip.setPixelColor(62+iCol, random(10,255), 0, 0);}//13-17 red
  50.             if (iRandom > 144){strip.setPixelColor(67+iCol, 0, 0,  random(100,255));}//18-21 blue
  51.            
  52.                         //if (iRandom > 95){strip.setPixelColor(13+iCol, 200, random(0,2), 255);}
  53.             //if (iRandom > 98){strip.setPixelColor(15+iCol, 255, random(200,255), 255);}
  54.                delay(.5);
  55.         }
  56.     }
  57.         strip.show();
  58. }
  59.  
  60. void loop() {
  61.  val = analogRead(potPin);    // read the value from the sensor
  62.  strip.setBrightness(val);//THIS WORKS!!!
  63.     modeFireplace();
  64. }
Advertisement
Add Comment
Please, Sign In to add comment