Hardware Reference
In-Depth Information
{
BLUE, YELLOW } //// 19
};
//// Other
int current = 0; //// LED in array with current focus
int previous = 0; //// Previous LED that was lit
void setup() {
Entropy.Initialize();
randomSeed(Entropy.random());
}
void loop() {
unsigned long loopCount = 0; // Used to determine duty cycle of
each LED
unsigned long timeNow = millis(); //
unsigned long displayTime = 10 + random(10); // Milliseconds to
spend at each
focus LED in descent
while(millis()- timeNow < (displayTime+current)) { // Animation
slows toward
end
loopCount++;
//// The "snowflake" gets full duty cycle. When it gets to the
end, hold it
at the end until the tail collapses.
if (current > 19) charlieOFF(19); //This is altered from the
original code,
to turn LEDs off once the blink is over
else charlieON(current);
//// Each member of tail has reduced duty cycle, and never gets
to the final
position
if(!(loopCount % 3)) if(current-1 >=0 && current-1 < 19)
charlieOFF(current-1);
if(!(loopCount % 6)) if(current-2 >=0 && current-2 < 19)
charlieOFF(current-2);
if(!(loopCount % 9)) if(current-3 >=0 && current-3 < 19)
charlieOFF(current-3);
if(!(loopCount % 12)) if(current-4 >=0 && current-4 < 19)
charlieOFF(current-4);
}
current++;
if(current==23) { //// start over
//Alicia commented out the below code to make the LEDs blink on
and off
rather than fade out.
//// Now fade out the snowflake in that final position #19
Search WWH ::




Custom Search