/* Project: default */
#include <FastLED.h>
#define DATA_PIN 22
#define LED_TYPE NEOPIXEL
#define NUM_LEDS 16
CRGBArray<NUM_LEDS> leds;
unsigned long tiempoNeopix_;
int contNeopix_;
void setup()
{
pinMode(2, INPUT);
FastLED.addLeds<LED_TYPE, DATA_PIN>(leds, NUM_LEDS);
FastLED.clear();
FastLED.show();
contNeopix_ = 0;
}
void loop()
{
if(digitalRead(2)){
if((millis()-tiempoNeopix_)>=((200))){
tiempoNeopix_=millis();
if (contNeopix_>= 0 && contNeopix_<= 16) {
if(contNeopix_-1< 0){
} else{
leds[contNeopix_-1] = 0x000000;}
FastLED.show();
leds[contNeopix_] = 0xff0000;
FastLED.show();
contNeopix_ = (contNeopix_+1);}}
if (contNeopix_ >= (1 + 16)) {
leds[contNeopix_-1] = 0x000000;
contNeopix_ = 0;}
}else { contNeopix_ = 0;
}
}
Loading
esp32-devkit-c-v4
esp32-devkit-c-v4