#include <FastLED.h>
#define NUM_LEDS 8
#define LED_PIN 8
#define pinPhoto 3
CRGB leds[NUM_LEDS];
int etatPhoto = HIGH ;
void setup() {
FastLED.addLeds<WS2812B, LED_PIN, GRB>(leds, NUM_LEDS);
FastLED.setBrightness(150);
pinMode(pinPhoto, INPUT_PULLUP);
}
void loop() {
static int compteurGong = 0;
etatPhoto = digitalRead(pinPhoto) ;
if (etatPhoto == LOW) {
compteurGong = compteurGong +1 ;
if (compteurGong == 5){
compteurGong = 0 ;
}
}
fill_solid(leds, NUM_LEDS, CRGB::Black);
FastLED.show();
delay(10);
switch(compteurGong){
case 1 :
fill_solid(leds, NUM_LEDS, CRGB::Red);
FastLED.show();
delay(100);
break ;
case 2 :
fill_solid(leds, NUM_LEDS, CRGB::Green);
FastLED.show();
delay(100);
break ;
case 3 :
fill_solid(leds, NUM_LEDS, CRGB::Blue);
FastLED.show();
delay(100);
break ;
default :
fill_solid(leds, NUM_LEDS, CRGB::Black);
FastLED.show();
delay(100);
break ;
}
}