Avec la librarie FastLED et quelques LED RGB Adressable (RB-Spa-967), on obtient des effets de lumieres interressants.
L’exemple ici est LEDStrip Effect – Snow Sparkle, mais a cette adresse on peux trouver plein d’autres exemples
Matériel
- LED Adressable – RB-SPA-967
- Arduino UNO compatible – RB-DFR-189
Code
#include "FastLED.h" #define NUM_LEDS 5 CRGB leds[NUM_LEDS]; #define PIN 6 void setup() { FastLED.addLeds<WS2811, PIN, GRB>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip ); } 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(); } void SnowSparkle(byte red, byte green, byte blue, int SparkleDelay, int SpeedDelay) { setAll(red,green,blue); int Pixel = random(NUM_LEDS); setPixel(Pixel,0xff,0xff,0xff); showStrip(); delay(SparkleDelay); setPixel(Pixel,red,green,blue); showStrip(); delay(SpeedDelay); } void loop() { SnowSparkle(0x10, 0x10, 0x10, 20, random(100,1000)); }