Portfolio. BHSAD Arduino Prototyping | L4, Harduino: Drawing light | Página 24
void loop() {
Fire(50,120,20);
}
void loop() {
RunningLights(0xff,0xff,0x00, 40);
}
void Fire(int Cooling,
int Sparking, int
SpeedDelay) {
static byte heat[NUM_
LEDS];
int cooldown;
void RunningLights(byte red, byte green, byte blue,
int WaveDelay) {
int Position=0;
for(int i=0; i= 2; k--) {
heat[k] = (heat[k - 1]
+ heat[k - 2] + heat[k -
2]) / 3;
}
// Step 1. Cool down
every cell a little
for( int i = 0; i < NUM_
LEDS; i++) {
cooldown = random(0,
((Cooling * 10) / NUM_
LEDS) + 2); // Step 3. Randomly
ignite new ‘sparks’ near
the bottom
if( random(255) <
Sparking ) {
int y = random(7);
heat[y] = heat[y] +
random(160,255);
//heat[y] =
random(160,255);
}
if(cooldown>heat[i]) {
heat[i]=0;
} else {
heat[i]=heat[i]-
cooldown;
}
} // Step 4. Convert heat
to LED colors
for( int j = 0; j < NUM_
LEDS; j++) {
setPixelHeatColor(j,
heat[j] );
}
// Step 2. Heat from
each cell drifts ‘up’ and
diffuses a little showStrip();
delay(SpeedDelay);
}
LED Strip Effects