63 lines
1.3 KiB
Arduino
63 lines
1.3 KiB
Arduino
|
#include "FastLED.h"
|
||
|
#define NUM_LEDS 60
|
||
|
CRGB leds[NUM_LEDS];
|
||
|
#define PIN 6
|
||
|
|
||
|
void setup()
|
||
|
{
|
||
|
FastLED.addLeds<WS2811, PIN, GRB>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
|
||
|
}
|
||
|
|
||
|
// *** REPLACE FROM HERE ***
|
||
|
void loop() {
|
||
|
theaterChase(0xff,0,0,50);
|
||
|
}
|
||
|
|
||
|
void theaterChase(byte red, byte green, byte blue, int SpeedDelay) {
|
||
|
for (int j=0; j<10; j++) { //do 10 cycles of chasing
|
||
|
for (int q=0; q < 3; q++) {
|
||
|
for (int i=0; i < NUM_LEDS; i=i+3) {
|
||
|
setPixel(i+q, red, green, blue); //turn every third pixel on
|
||
|
}
|
||
|
showStrip();
|
||
|
|
||
|
delay(SpeedDelay);
|
||
|
|
||
|
for (int i=0; i < NUM_LEDS; i=i+3) {
|
||
|
setPixel(i+q, 0,0,0); //turn every third pixel off
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
// *** REPLACE TO HERE ***
|
||
|
|
||
|
void showStrip() {
|
||
|
#ifdef ADAFRUIT_NEOPIXEL_H
|
||
|
// NeoPixel
|
||
|
strip.show();
|
||
|
#endif
|
||
|
#ifndef ADAFRUIT_NEOPIXEL_H
|
||
|
// FastLED
|
||
|
FastLED.show();
|
||
|
#endif
|
||
|
}
|
||
|
|
||
|
void setPixel(int Pixel, byte red, byte green, byte blue) {
|
||
|
#ifdef ADAFRUIT_NEOPIXEL_H
|
||
|
// NeoPixel
|
||
|
strip.setPixelColor(Pixel, strip.Color(red, green, blue));
|
||
|
#endif
|
||
|
#ifndef ADAFRUIT_NEOPIXEL_H
|
||
|
// FastLED
|
||
|
leds[Pixel].r = red;
|
||
|
leds[Pixel].g = green;
|
||
|
leds[Pixel].b = blue;
|
||
|
#endif
|
||
|
}
|
||
|
|
||
|
void setAll(byte red, byte green, byte blue) {
|
||
|
for(int i = 0; i < NUM_LEDS; i++ ) {
|
||
|
setPixel(i, red, green, blue);
|
||
|
}
|
||
|
showStrip();
|
||
|
}
|