KVEL

Jack O Lantern

Oct 28th, 2020 (edited)
417
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.35 KB | None | 0 0
  1. //************************************************************************
  2. //*** Code by: spyclub ***************************************************
  3. //***https://www.instructables.com/Arduino-Controlled-Electric-Candle/****
  4. //***https://www.thingiverse.com/thing:4640101****************************
  5. //************************************************************************
  6.  
  7. #include <Adafruit_NeoPixel.h>
  8. #define DELAY_MULTIPLER 50
  9. #define PIN 1
  10.  
  11. Adafruit_NeoPixel strip = Adafruit_NeoPixel(12 , PIN, NEO_GRB + NEO_KHZ800);
  12.  
  13. void setup() {
  14.   strip.begin();
  15.   strip.show();
  16. }
  17.  
  18. void loop()
  19. {
  20.   fire(1,random(50,500));  
  21. }
  22.  
  23. void fire(uint8_t wait, uint8_t times)
  24. {
  25.   for(uint16_t t=0; t < times; t++)
  26.   {
  27.     uint32_t cBaseYellow = strip.Color(255, 100, 10);
  28.     uint32_t redFilcker = strip.Color(255, 40, 0);
  29.     uint32_t blueFilcker = strip.Color(255, 100, 100);
  30.    
  31.     for(uint16_t i=0; i<strip.numPixels(); i++)
  32.     {
  33.       strip.setPixelColor(i, cBaseYellow);
  34.     }
  35.  
  36.     uint8_t blue;
  37.     for(uint16_t i=0; i<1; i++)
  38.     {
  39.       blue = random(1,strip.numPixels());
  40.       strip.setPixelColor(blue, blueFilcker);
  41.     }
  42.  
  43.     uint8_t red;
  44.     for(uint16_t i=0; i<4; i++)
  45.     {
  46.       red = random(1,strip.numPixels());
  47.       strip.setPixelColor(red, redFilcker);
  48.     }
  49.    
  50.     strip.show();
  51.     delay(wait*DELAY_MULTIPLER);
  52.   }
  53. }
Add Comment
Please, Sign In to add comment