void setup() { pinMode(2, OUTPUT); pinMode(3, OUTPUT); Serial.begin(9600); } void ciclo1() { int i=0; while (i < 5) { digitalWrite(3, LOW); digitalWrite(2, HIGH); delay(500); digitalWrite(2, LOW); digitalWrite(3, HIGH); delay(500); ++i; } apagaLeds(); } void ciclo2() { int j=0; while (j < 5) { digitalWrite(3, LOW); digitalWrite(2, HIGH); delay(50); digitalWrite(2, LOW); digitalWrite(2, HIGH); delay(50); digitalWrite(2, LOW); digitalWrite(3, HIGH); delay(50); digitalWrite(3, LOW); digitalWrite(3, HIGH); ++j; } apagaLeds(); } void apagaLeds() { digitalWrite(2, LOW); digitalWrite(3, LOW); } void loop() { int serialCom; if (Serial.available() > 0) { serialCom = Serial.read(); Serial.print("Valor Recibido : "); Serial.println(serialCom); switch (serialCom) { case 49: ciclo1(); break; case 50: ciclo2(); break; default: apagaLeds(); } delay(100); Serial.read(); } }