ébauche lampe bande led
This commit is contained in:
@@ -0,0 +1,82 @@
|
|||||||
|
#include <FastLED.h>
|
||||||
|
|
||||||
|
/*==========variables LED*/
|
||||||
|
constexpr uint8_t NBR_LED = 40;
|
||||||
|
|
||||||
|
constexpr uint8_t DATA = 27;
|
||||||
|
constexpr uint8_t CLOCK = 26;
|
||||||
|
|
||||||
|
constexpr uint8_t BRIGHTNESS = 255;
|
||||||
|
|
||||||
|
CRGB leds[NBR_LED];
|
||||||
|
|
||||||
|
/*===========commutateur ambiance*/
|
||||||
|
constexpr uint8_t AMBIANCE_CHECK = 22;
|
||||||
|
|
||||||
|
/*============on:off*/
|
||||||
|
constexpr uint8_t ON_CHECK = 23;
|
||||||
|
|
||||||
|
/*===========animation aller-retour*/
|
||||||
|
void loadingAnimation(){
|
||||||
|
for(int i = 0; i<NBR_LED; i++){
|
||||||
|
leds[i] = CRGB::Green;
|
||||||
|
FastLED.show();
|
||||||
|
delay(33);
|
||||||
|
}
|
||||||
|
|
||||||
|
delay(3333);
|
||||||
|
|
||||||
|
for(int i = 0; i<=NBR_LED; i++){
|
||||||
|
leds[NBR_LED-i] = CRGB::Purple;
|
||||||
|
FastLED.show();
|
||||||
|
delay(33);
|
||||||
|
}
|
||||||
|
|
||||||
|
delay(3333);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*=============animation shut down*/
|
||||||
|
void allOff(){
|
||||||
|
for(int i = 0; i<NBR_LED; i++){
|
||||||
|
leds[NBR_LED-1-i] = CRGB(0,0,0);
|
||||||
|
FastLED.show();
|
||||||
|
delay(33);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*=============animation "on voit rien pauv' con <3"*/
|
||||||
|
void allBright(){
|
||||||
|
for(int i = 0; i<NBR_LED; i++){
|
||||||
|
leds[i] = CRGB(255,255,200);
|
||||||
|
FastLED.show();
|
||||||
|
delay(33);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*==============MAIN EVENT MUAHAHAHA*/
|
||||||
|
void setup(){
|
||||||
|
FastLED.addLeds<APA102, DATA, CLOCK, BGR>(leds, NBR_LED);
|
||||||
|
FastLED.setBrightness(BRIGHTNESS);
|
||||||
|
|
||||||
|
FastLED.clear();
|
||||||
|
leds[3] = CRGB::Red;
|
||||||
|
FastLED.show();
|
||||||
|
FastLED.clear();
|
||||||
|
|
||||||
|
pinMode(AMBIANCE_CHECK, INPUT_PULLUP);
|
||||||
|
pinMode(ON_CHECK, INPUT_PULLUP);
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop(){
|
||||||
|
if(digitalRead(ON_CHECK)==LOW){
|
||||||
|
if(digitalRead(AMBIANCE_CHECK)==LOW){
|
||||||
|
loadingAnimation();
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
allBright();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
FastLED.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user