/*------------------------------------------------------- PRUEBA DE LEDS - ARDUINO NANO LED1 -> D13 LED2 -> D12 Encender LED1 por 500ms, luego LED2 por 500ms. Autor: [Ja-Bots.com] Fecha: [2025] -------------------------------------------------------*/ // Definición de pines #define LED1 13 #define LED2 12 // Prototipos de funciones void encenderLed(int pin, int tiempo); void rutinaPrincipal(); void rutinaLlamativa(); void setup() { // Configuración de pines como salida pinMode(LED1, OUTPUT); pinMode(LED2, OUTPUT); } void loop() { rutinaPrincipal(); rutinaLlamativa(); } /*------------------------------------------------------- Función: encenderLed Descripción: Enciende el LED indicado durante el tiempo especificado. Parámetros: - pin: número de pin del LED - tiempo: duración en milisegundos -------------------------------------------------------*/ void encenderLed(int pin, int tiempo) { digitalWrite(pin, HIGH); delay(tiempo); digitalWrite(pin, LOW); delay(tiempo); } /*------------------------------------------------------- Función: rutinaPrincipal Descripción: Prueba básica de LEDs alternados. -------------------------------------------------------*/ void rutinaPrincipal() { encenderLed(LED1, 500); encenderLed(LED2, 500); } /*------------------------------------------------------- Función: rutinaLlamativa Descripción: Efecto visual con parpadeo alternado rápido. -------------------------------------------------------*/ void rutinaLlamativa() { for (int i = 0; i < 5; i++) { digitalWrite(LED1, HIGH); digitalWrite(LED2, LOW); delay(100); digitalWrite(LED1, LOW); digitalWrite(LED2, HIGH); delay(100); } // Ambos encendidos brevemente al final digitalWrite(LED1, HIGH); digitalWrite(LED2, HIGH); delay(300); digitalWrite(LED1, LOW); digitalWrite(LED2, LOW); delay(300); }