Advertisement
Guest User

Untitled

a guest
Nov 4th, 2014
367
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.90 KB | None | 0 0
  1. void Fire2012()
  2. {
  3. // Array of temperature readings at each simulation cell
  4.   static byte heat[NUM_LEDS];
  5.  
  6.   // Step 1.  Cool down every cell a little
  7.     for( int i = 0; i < NUM_LEDS; i++) {
  8.       heat[i] = qsub8( heat[i],  random8(0, ((COOLING * 10) / NUM_LEDS) + 2));
  9.     }
  10.  
  11.     // Step 2.  Heat from each cell drifts 'up' and diffuses a little
  12.     for( int k= NUM_LEDS - 1; k >= 2; k--) {
  13.       heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3;
  14.     }
  15.    
  16.     // Step 3.  Randomly ignite new 'sparks' of heat near the bottom
  17.     if( random8() < SPARKING ) {
  18.       int y = random8(7);
  19.       heat[y] = qadd8( heat[y], random8(160,255) );
  20.     }
  21.  
  22.     // Step 4.  Map from heat cells to LED colors
  23.     for( int j = 0; j < NUM_LEDS; j++) {
  24.         leds[j] = HeatColor( heat[j]);
  25.         strip.setPixelColor(j,leds[j].red,leds[j].green,leds[j].blue);//Conversion not working well
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement