const int greenLed = D2; const int redLed = D3; // Configuración PWM const int pwmFreq = 5000; const int pwmResolution = 8; const int greenChannel = 0; const int redChannel = 1; // Control del tiempo (~2 segundos por transición) const int stepDelay = 8; void setup() { // Asignar cada pin a un canal PWM distinto ledcAttachChannel(greenLed, pwmFreq, pwmResolution, greenChannel); ledcAttachChannel(redLed, pwmFreq, pwmResolution, redChannel); // Estado inicial ledcWriteChannel(greenChannel, 0); ledcWriteChannel(redChannel, 255); } void loop() { // Verde sube, rojo baja for (int value = 0; value <= 255; value++) { ledcWriteChannel(greenChannel, value); ledcWriteChannel(redChannel, 255 - value); delay(stepDelay); } // Verde baja, rojo sube for (int value = 255; value >= 0; value--) { ledcWriteChannel(greenChannel, value); ledcWriteChannel(redChannel, 255 - value); delay(stepDelay); } }