Portfolio. BHSAD Arduino Prototyping | L4, Harduino: Drawing light | 页面 23
delay(EndPause);
}
for(int i = 0; i < NUM_
LEDS-EyeSize-2; i++) {
setAll(0,0,0);
setPixel(i, red/10,
green/10, blue/10);
for(int j = 1; j <=
EyeSize; j++) {
setPixel(i+j, red,
green, blue);
}
setPixel(i+EyeSize+1,
red/10, green/10,
blue/10);
showStrip();
delay(SpeedDelay);
}
delay(ReturnDelay);
for(int i = NUM_LEDS-
EyeSize-2; i > 0; i--) {
setAll(0,0,0);
setPixel(i, red/10,
green/10, blue/10);
for(int j = 1; j <=
EyeSize; j++) {
setPixel(i+j, red,
green, blue);
}
setPixel(i+EyeSize+1,
red/10, green/10,
blue/10);
showStrip();
delay(SpeedDelay);
}
void loop() {
//Sparkle(random(255), random(255), random(255), 10);
//random color
Sparkle(0xec, 0x70, 0xff, 10);
}
void Sparkle(byte red, byte green, byte blue, int
SpeedDelay) {
int Pixel = random(NUM_LEDS);
setPixel(Pixel,red,green,blue);
showStrip();
delay(SpeedDelay);
setPixel(Pixel,0,0,0);
}
delay(ReturnDelay);
}
void Strobe(byte red, byte green, byte blue, int
StrobeCount, int FlashDelay, int EndPause){
for(int j = 0; j < StrobeCount; j++) {
setAll(red,green,blue);
showStrip();
delay(FlashDelay);
setAll(0,0,0);
showStrip();
delay(FlashDelay);
}
void CylonBounce(byte
red, byte green, byte
blue, int EyeSize,
int SpeedDelay, int
ReturnDelay){
void loop() {
// Slower:
Strobe(0xff, 0x77, 0x00, 10, 100, 1000);
// Fast:
//Strobe(0xff, 0xff, 0xff, 10, 50, 1000);
}
void loop() {
CylonBounce(0x4a, 0xff,
0xa4, 4, 40, 50);
}