2021-01-05 00:15:16 -03:00
|
|
|
void setup() {
|
2022-04-04 15:22:18 -04:00
|
|
|
pinMode(2, OUTPUT);
|
|
|
|
pinMode(3, OUTPUT);
|
|
|
|
Serial.begin(9600);
|
2021-01-05 00:15:16 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
void ciclo1() {
|
2022-04-04 15:22:18 -04:00
|
|
|
int i=0;
|
|
|
|
while (i < 5) {
|
|
|
|
digitalWrite(3, LOW);
|
|
|
|
digitalWrite(2, HIGH);
|
|
|
|
delay(500);
|
|
|
|
digitalWrite(2, LOW);
|
|
|
|
digitalWrite(3, HIGH);
|
|
|
|
delay(500);
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
apagaLeds();
|
2021-01-05 00:15:16 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
void ciclo2() {
|
2022-04-04 15:22:18 -04:00
|
|
|
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();
|
2021-01-05 00:15:16 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
void apagaLeds() {
|
|
|
|
digitalWrite(2, LOW);
|
|
|
|
digitalWrite(3, LOW);
|
|
|
|
}
|
|
|
|
|
|
|
|
void loop() {
|
2022-04-04 15:22:18 -04:00
|
|
|
int serialCom;
|
|
|
|
if (Serial.available() > 0) {
|
|
|
|
serialCom = Serial.read();
|
|
|
|
Serial.print("Valor Recibido : ");
|
|
|
|
Serial.println(serialCom);
|
2022-04-04 17:41:38 -04:00
|
|
|
switch (serialCom) {
|
|
|
|
case 49:
|
|
|
|
ciclo1();
|
|
|
|
break;
|
|
|
|
case 50:
|
|
|
|
ciclo2();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
apagaLeds();
|
|
|
|
}
|
|
|
|
delay(100);
|
|
|
|
Serial.read();
|
2022-04-04 15:22:18 -04:00
|
|
|
}
|
|
|
|
}
|