Created
April 18, 2020 08:18
-
-
Save jecrespo/487c77e6815f0b960e68c5ca2701a727 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
#include <LiquidCrystal.h> | |
byte const interruptPin2 = 2; | |
byte const interruptPin3 = 3; | |
int estado; | |
int cuenta; | |
unsigned long inicial; | |
int minutos; | |
int segundos; | |
int horas; | |
LiquidCrystal lcd(12, 11, 7, 6, 5, 4); | |
void setup() { | |
pinMode(interruptPin2, INPUT_PULLUP); | |
pinMode(interruptPin3, INPUT_PULLUP); | |
attachInterrupt(digitalPinToInterrupt(interruptPin2), salida, FALLING); | |
attachInterrupt(digitalPinToInterrupt(interruptPin3), stop1, FALLING); | |
//fijar número la pantalla del LCD de filas y columnas: | |
lcd.begin (16, 2); | |
lcd.setCursor(1, 0); | |
lcd.print ("tiempo transcurrido:"); | |
lcd.setCursor(3, 1); | |
lcd.print(":"); | |
lcd.setCursor(7, 1); | |
lcd.print(":"); | |
lcd.setCursor(11, 1); | |
lcd.print(":"); | |
} | |
void loop() { | |
inicial = millis(); | |
segundos = 0; | |
minutos = 0; | |
horas = 0; | |
while (estado) { | |
int count = millis() - inicial; | |
if (count > 999) { | |
inicial += 1000; | |
segundos++; | |
if (segundos > 59) { | |
segundos = 00; | |
lcd.setCursor(9, 1); | |
lcd.print(""); | |
minutos ++; | |
if (minutos > 59) { | |
minutos = 0; | |
lcd.setCursor(5, 1); | |
lcd.print(""); | |
horas ++; | |
} | |
} | |
} | |
lcd.setCursor(0, 1); | |
lcd.print(horas); | |
lcd.setCursor(4, 1); | |
lcd.print(minutos); | |
lcd.setCursor(8, 1); | |
lcd.print(segundos); | |
lcd.setCursor(12, 1); | |
lcd.print(count); | |
} | |
} | |
void salida() { | |
estado = 1; | |
} | |
void stop1() { | |
estado = 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment