Skip to content

Instantly share code, notes, and snippets.

@esmarr58
Created November 26, 2017 23:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save esmarr58/91240514b16f2efc4d039f50b5179e06 to your computer and use it in GitHub Desktop.
Save esmarr58/91240514b16f2efc4d039f50b5179e06 to your computer and use it in GitHub Desktop.
unsigned long tiempo1 = 0;
unsigned long tiempo2 = 0;
unsigned long tiempoSegundos = 0;
void setup() {
Serial.begin(9600);
tiempo1 = millis();
}
void loop() {
tiempo2 = millis();
if(tiempo2 > (tiempo1+1000)){ //Si ha pasado 1 segundo ejecuta el IF
tiempo1 = millis(); //Actualiza el tiempo actual
tiempoSegundos = tiempo1/1000;
Serial.print("Ha transcurrido: ");
Serial.print(tiempoSegundos);
Serial.println(" desde que se encendio el Arduino");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment