1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| #include "FastLED.h"
// Fastled constants
#define DATA_PIN 2
#define COLOR_ORDER GRB
#define NUM_LEDS 16
#define LED_TYPE WS2812B
#define BRIGHTNESS 64
CRGB leds[NUM_LEDS];
#define LED_PIN 1 // Built in LED
void setup() {
FastLED.addLeds<LED_TYPE, DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS);
FastLED.setCorrection( TypicalLEDStrip );
FastLED.setBrightness( BRIGHTNESS );
FastLED.clear();
pinMode(LED_PIN, OUTPUT);
}
void loop() {
anim1();
}
void anim1() {
fill_solid (leds, NUM_LEDS, CRGB::Red);
FastLED.show();
digitalWrite(LED_PIN, LOW); // Turn the LED on
delay(200);
fill_solid (leds, NUM_LEDS, CRGB::Blue);
FastLED.show();
delay(200);
fill_solid (leds, NUM_LEDS, CRGB::Green);
FastLED.show();
digitalWrite(LED_PIN, HIGH); // Turn the LED off
delay(200);
fill_solid (leds, NUM_LEDS, CRGB::White);
FastLED.show();
delay(200);
} |
Partager