mathiaspl20

blink(1)

Jan 4th, 2017
77
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <Adafruit_NeoPixel.h>
  2. #ifdef __AVR__
  3. #include <avr/power.h>
  4. #endif
  5. #define PIN            0
  6. #define NUMPIXELS      21
  7.  
  8. Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
  9.  
  10. int delayval = 100;
  11.  
  12. void setup() {
  13.   pixels.begin();
  14. }
  15.  
  16. void loop() {
  17.  
  18.   // For a set of NeoPixels the first NeoPixel is 0, second is 1, all the way up to the count of pixels minus one.
  19.  
  20.   for(int i=-1;i<NUMPIXELS;){
  21. if (i < NUMPIXELS-1){
  22.       i++;
  23.       pixels.setPixelColor(i, pixels.Color(0,255,0));
  24.      
  25.     pixels.show();
  26.     delay(delayval);
  27.    
  28. }
  29. else{
  30.   for(i>=-1;i+1;){
  31.      
  32.      pixels.setPixelColor(i, pixels.Color(0,0,255));
  33.     i--;
  34.     pixels.show();
  35.     delay(delayval);
  36.    
  37.   }
  38.   }
  39.   }
  40.   }
RAW Paste Data