SHARE
TWEET

purple fade

a guest Aug 24th, 2019 79 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <Adafruit_NeoPixel.h>
  2.  
  3. #define PIN 6
  4. #define NUMLEDS 60
  5. #define BRIGHTNESS 25 // 0-255 max brightness 'number of steps'
  6. #define COLOR 255, 0, 175 // rgb value
  7. #define DELAY 75 // in milliseconds between 'steps'
  8.  
  9. // Parameter 1 = number of pixels in strip
  10. // Parameter 2 = Arduino pin number (most are valid)
  11. // Parameter 3 = pixel type flags, add together as needed:
  12. //   NEO_KHZ800  800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
  13. //   NEO_KHZ400  400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
  14. //   NEO_GRB     Pixels are wired for GRB bitstream (most NeoPixel products)
  15. //   NEO_RGB     Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
  16. Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUMLEDS, PIN, NEO_GRB + NEO_KHZ800);
  17.  
  18. boolean flag;
  19.  
  20. void setup() {
  21.   // put your setup code here, to run once:
  22.  
  23.   strip.begin();
  24.   strip.show(); // Initialize all pixels to 'off'
  25.   strip.setBrightness(BRIGHTNESS);
  26.   strip.fill(strip.Color(COLOR), 0, NUMLEDS);
  27. }
  28.  
  29.  
  30. void loop() {
  31.  
  32.   strip.fill(strip.Color(COLOR), 0, NUMLEDS);
  33.  
  34.   if (flag){
  35.     brighten();
  36.   }
  37.   else{
  38.     darken();
  39.   }
  40.  
  41.   if (strip.getBrightness() == 0 || strip.getBrightness() >= BRIGHTNESS)
  42.     flag = !flag;
  43.  
  44.   strip.show();
  45.   delay(DELAY); // adjust time between brightness steps
  46. }
  47.  
  48.  
  49. // brighten strip
  50. void brighten() {
  51.   strip.setBrightness(strip.getBrightness() + 1);
  52. }
  53.  
  54. // darken strip
  55. void darken() {
  56.   strip.setBrightness(strip.getBrightness() - 1);
  57. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top