Created
November 26, 2017 23:52
-
-
Save esmarr58/4d2d1e50e1784785e18b3ebb0ea04d6c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
unsigned long tiempo1 = 0; | |
unsigned long tiempo2 = 0; | |
unsigned long diferenciaTiempo = 0; | |
void setup() { | |
Serial.begin(9600); | |
Serial.println("Envie la letra A o a por la terminal serial"); | |
} | |
void loop() { | |
if(Serial.available() > 0){ | |
char datoRecibido = Serial.read(); | |
if(datoRecibido == 'A' || datoRecibido == 'a'){ | |
tiempo1 = millis(); | |
Serial.println("Envie la letra B o b por la terminal Serial"); | |
} | |
else if(datoRecibido == 'b' && datoRecibido == 'B'){ | |
tiempo2 = millis(); | |
diferenciaTiempo = tiempo1-tiempo2; | |
Serial.print("El tiempo transcurrido entre el primer dato enviado y el ultimo es: "); | |
Serial.print(diferenciaTiempo); | |
Serial.println("Envie la letra A o a por la terminal serial"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment