Advertisement
dangeraaron

CustomFireArray

Aug 6th, 2015
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.99 KB | None | 0 0
  1. #include <FastLED.h>
  2. #define BRIGHTNESS 200
  3. #define FRAMES_PER_SECOND 60
  4. #define SPARKING 255
  5. #define COOLING 85
  6.  
  7. #define Z1_DATAPIN 1 //Declare Zone 1 data pin
  8. #define Z1_LEDS 50 //Declare Zone 1 number of LEDs
  9. CRGB Z1[Z1_LEDS]; //Declare Zone 1 FastLED data array
  10. byte Z1_Heat[Z1_LEDS]; //Delcare Zone 1 Heat map data array
  11.  
  12. #define Z2_DATAPIN 2 //Declare Zone 2 data pin
  13. #define Z2_LEDS 61 //Declare Zone 2 number of LEDs
  14. CRGB Z2[Z2_LEDS]; //Declare Zone 2 FastLED data array
  15. byte Z2_Heat[Z2_LEDS]; //Delcare Zone 2 Heat map data array
  16.  
  17. #define Z3_DATAPIN 3 //Declare Zone 3 data pin
  18. #define Z3_LEDS 52 //Declare Zone 3 number of LEDs
  19. CRGB Z3[Z3_LEDS]; //Declare Zone 3 FastLED data array
  20. byte Z3_Heat[Z3_LEDS]; //Delcare Zone 3 Heat map data array
  21.  
  22. #define Z4_DATAPIN 4 //Declare Zone 4 data pin
  23. #define Z4_LEDS 44 //Declare Zone 4 number of LEDs
  24. CRGB Z4[Z4_LEDS]; //Declare Zone 4 FastLED data array
  25. byte Z4_Heat[Z4_LEDS]; //Delcare Zone 4 Heat map data array
  26.  
  27. #define Z5_DATAPIN 5 //Declare Zone 5 data pin
  28. #define Z5_LEDS 41 //Declare Zone 5 number of LEDs
  29. CRGB Z5[Z5_LEDS]; //Declare Zone 5 FastLED data array
  30. byte Z5_Heat[Z5_LEDS]; //Delcare Zone 5 Heat map data array
  31.  
  32. #define Z6_DATAPIN 6 //Declare Zone 6 data pin
  33. #define Z6_LEDS 40 //Declare Zone 6 number of LEDs
  34. CRGB Z6[Z6_LEDS]; //Declare Zone 6 FastLED data array
  35. byte Z6_Heat[Z6_LEDS]; //Delcare Zone 6 Heat map data array
  36.  
  37.  
  38. CRGBPalette16 gPal; //Set pallet array
  39.  
  40. void setup()
  41. {
  42. delay(2000);
  43. FastLED.addLeds<WS2812B, Z1_DATAPIN, GRB>(Z1, 0, Z1_LEDS);
  44. FastLED.addLeds<WS2812B, Z2_DATAPIN, GRB>(Z2, 0, Z2_LEDS);
  45. FastLED.addLeds<WS2812B, Z3_DATAPIN, GRB>(Z3, 0, Z3_LEDS);
  46. FastLED.addLeds<WS2812B, Z4_DATAPIN, GRB>(Z4, 0, Z4_LEDS);
  47. FastLED.addLeds<WS2812B, Z5_DATAPIN, GRB>(Z5, 0, Z5_LEDS);
  48. FastLED.addLeds<WS2812B, Z6_DATAPIN, GRB>(Z6, 0, Z6_LEDS);
  49.  
  50. FastLED.setBrightness(100);
  51. //gPal = HeatColors_p;
  52.  
  53. // gPal = CRGBPalette16( CRGB::Black, CRGB::Red, CRGB::Yellow, CRGB::White);
  54.  
  55. // gPal = CRGBPalette16( CRGB::Black, CRGB::Blue, CRGB::Aqua, CRGB::White);
  56.  
  57. // gPal = CRGBPalette16( CRGB::Black, CRGB::Red, CRGB::White);
  58.  
  59. gPal = CRGBPalette16( CRGB::Black, CRGB::Green, CRGB::YellowGreen, CRGB::White);
  60.  
  61. }
  62.  
  63. void loop() {
  64.  
  65. random16_add_entropy( random());
  66. Fire2012(Z1_Heat, Z1, Z1_LEDS);
  67. Fire2012(Z2_Heat, Z2, Z2_LEDS);
  68. Fire2012(Z3_Heat, Z3, Z3_LEDS);
  69. Fire2012(Z4_Heat, Z4, Z4_LEDS);
  70. Fire2012(Z5_Heat, Z5, Z5_LEDS);
  71. Fire2012(Z6_Heat, Z6, Z6_LEDS);
  72. FastLED.show();
  73. FastLED.delay(1000 / FRAMES_PER_SECOND);
  74. }
  75.  
  76. void Fire2012(byte *heat, CRGB *leds, int number_leds) //Might not need the "*" in front of the arrays...
  77. {
  78.  
  79. for( int i = 0; i < number_leds; i++) {
  80. heat[i] = qsub8(heat[i], random8(0, ((COOLING * 10) / number_leds) + 2));
  81. }
  82.  
  83. for( byte k= number_leds - 1; k >= 2; k--) {
  84. heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3;
  85. }
  86.  
  87. if( random8() < SPARKING ) {
  88. int y = random8(7);
  89. heat[y] = qadd8( heat[y], random8(160,255) );
  90. }
  91.  
  92. for( int j = 0; j < number_leds; j++) {
  93. //leds[j] = HeatColor(heat[j]);
  94. byte colorindex = scale8( heat[number_leds-j], 240);
  95. leds[j] = ColorFromPalette( gPal, colorindex);
  96.  
  97. }
  98. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement