#include <FastLED.h>
#define NUM_LEDS 15 /*the number of leds that will light. If */
//****************************
#define DATA_PINA 9
#define DATA_PINB 8
#define DATA_PINC 7
#define DATA_PIND 6
#define RELAY_PIN 5 // Pin del relé
CRGB ledsA[NUM_LEDS]; // sets number of pixels that will light on each strip.
CRGB ledsB[NUM_LEDS];
CRGB ledsC[NUM_LEDS];
CRGB ledsD[NUM_LEDS];
bool relayActive = false;
//*****************************************************
void setup() {
FastLED.addLeds<WS2812B, DATA_PINA, GRB>(ledsA, NUM_LEDS);
FastLED.addLeds<WS2812B, DATA_PINB, GRB>(ledsB, NUM_LEDS);
FastLED.addLeds<WS2812B, DATA_PINC, GRB>(ledsC, NUM_LEDS);
FastLED.addLeds<WS2812B, DATA_PIND, GRB>(ledsD, NUM_LEDS);
randomSeed(analogRead(A0));
// Configura el pin del relé como salida
pinMode(RELAY_PIN, OUTPUT);
// Apaga inicialmente el relé
digitalWrite(RELAY_PIN, LOW);
}
//********************************************************
void loop() {
if (!relayActive) {
despertador();
}
}
//**************************************************
void fillStrip(int number, const struct CRGB &color) {
switch (number) {
case 1:
fill_solid(ledsA, NUM_LEDS, color);
break;
case 2:
fill_solid(ledsB, NUM_LEDS, color);
break;
case 3:
fill_solid(ledsC, NUM_LEDS, color);
break;
case 4:
fill_solid(ledsD, NUM_LEDS, color);
break;
}
FastLED.show();
}
//**************************************************
void despertador() {
int transitionDuration = 30000;
int steps = 30;
int delayTime = transitionDuration / steps;
CRGB colors[] = {
CRGB(0, 0, 0), // Negro
CRGB(10, 5, 0), // Amarillo oscuro
CRGB(20, 10, 0), // Amarillo más oscuro
CRGB(30, 15, 0), // Amarillo profundo
CRGB(40, 20, 0), // Amarillo intenso
CRGB(50, 25, 0), // Amarillo claro
CRGB(60, 30, 0), // Amarillo más claro
CRGB(70, 35, 0), // Amarillo muy claro
CRGB(80, 40, 0), // Amarillo
CRGB(90, 45, 0), // Amarillo
CRGB(100, 50, 0), // Amarillo
CRGB(110, 55, 0), // Amarillo
CRGB(120, 60, 0), // Amarillo
CRGB(130, 65, 0), // Amarillo
CRGB(140, 70, 0), // Amarillo
CRGB(150, 75, 0), // Amarillo
CRGB(160, 80, 0), // Amarillo
CRGB(170, 85, 0), // Amarillo
CRGB(180, 90, 0), // Amarillo
CRGB(190, 95, 0), // Amarillo
CRGB(200, 100, 0), // Amarillo
CRGB(210, 105, 0), // Amarillo
CRGB(220, 110, 0), // Amarillo
CRGB(230, 115, 0), // Amarillo
CRGB(240, 120, 0), // Amarillo
CRGB(250, 125, 0), // Amarillo
CRGB(255, 130, 0), // Naranja (plena luz del día)
};
for (int step = 0; step < steps; step++) {
int colorIndex = map(step, 0, steps - 1, 0, sizeof(colors) / sizeof(colors[0]));
CRGB color = colors[colorIndex];
fillStrip(1, color);
fillStrip(2, color);
fillStrip(3, color);
fillStrip(4, color);
FastLED.show();
delay(delayTime);
}
// Activa el relé al final de la secuencia
digitalWrite(RELAY_PIN, HIGH);
relayActive = true;
}