reloj
Dependencies: Debounced TextLCD mbed
main.cpp@0:1cb6019bbd61, 2016-04-06 (annotated)
- Committer:
- OlySolano
- Date:
- Wed Apr 06 17:17:37 2016 +0000
- Revision:
- 0:1cb6019bbd61
reloj
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
OlySolano | 0:1cb6019bbd61 | 1 | #include "mbed.h" |
OlySolano | 0:1cb6019bbd61 | 2 | //#include "DebouncedIn.h" |
OlySolano | 0:1cb6019bbd61 | 3 | #include "TextLCD.h" |
OlySolano | 0:1cb6019bbd61 | 4 | |
OlySolano | 0:1cb6019bbd61 | 5 | Serial pc(USBTX,USBRX); |
OlySolano | 0:1cb6019bbd61 | 6 | TextLCD lcd(PTB9, PTB10, PTE2, PTE3, PTE4, PTE5); |
OlySolano | 0:1cb6019bbd61 | 7 | DigitalOut myled(LED1); |
OlySolano | 0:1cb6019bbd61 | 8 | DigitalIn pulsador1 (D3); |
OlySolano | 0:1cb6019bbd61 | 9 | DigitalIn pulsador2 (D4); |
OlySolano | 0:1cb6019bbd61 | 10 | int horas; |
OlySolano | 0:1cb6019bbd61 | 11 | int minutos; |
OlySolano | 0:1cb6019bbd61 | 12 | int segundos; |
OlySolano | 0:1cb6019bbd61 | 13 | DigitalOut alarma (D6); |
OlySolano | 0:1cb6019bbd61 | 14 | Timer t; |
OlySolano | 0:1cb6019bbd61 | 15 | |
OlySolano | 0:1cb6019bbd61 | 16 | int main() |
OlySolano | 0:1cb6019bbd61 | 17 | { |
OlySolano | 0:1cb6019bbd61 | 18 | lcd.cls(); |
OlySolano | 0:1cb6019bbd61 | 19 | t.start(); |
OlySolano | 0:1cb6019bbd61 | 20 | do |
OlySolano | 0:1cb6019bbd61 | 21 | { |
OlySolano | 0:1cb6019bbd61 | 22 | |
OlySolano | 0:1cb6019bbd61 | 23 | segundos = t.read(); |
OlySolano | 0:1cb6019bbd61 | 24 | if(segundos == 60){ |
OlySolano | 0:1cb6019bbd61 | 25 | segundos=0; |
OlySolano | 0:1cb6019bbd61 | 26 | t.reset(); |
OlySolano | 0:1cb6019bbd61 | 27 | minutos++; |
OlySolano | 0:1cb6019bbd61 | 28 | |
OlySolano | 0:1cb6019bbd61 | 29 | } |
OlySolano | 0:1cb6019bbd61 | 30 | if(minutos==60){ |
OlySolano | 0:1cb6019bbd61 | 31 | minutos=0; |
OlySolano | 0:1cb6019bbd61 | 32 | horas++; |
OlySolano | 0:1cb6019bbd61 | 33 | |
OlySolano | 0:1cb6019bbd61 | 34 | } |
OlySolano | 0:1cb6019bbd61 | 35 | if(horas==24){ |
OlySolano | 0:1cb6019bbd61 | 36 | horas=0; |
OlySolano | 0:1cb6019bbd61 | 37 | } |
OlySolano | 0:1cb6019bbd61 | 38 | |
OlySolano | 0:1cb6019bbd61 | 39 | lcd.locate(0,1); |
OlySolano | 0:1cb6019bbd61 | 40 | lcd.printf("0%d:0%d:%d", horas, minutos, segundos); |
OlySolano | 0:1cb6019bbd61 | 41 | lcd.locate(2,0); |
OlySolano | 0:1cb6019bbd61 | 42 | lcd.printf("La hora es:"); |
OlySolano | 0:1cb6019bbd61 | 43 | |
OlySolano | 0:1cb6019bbd61 | 44 | } |
OlySolano | 0:1cb6019bbd61 | 45 | while(1);{ |
OlySolano | 0:1cb6019bbd61 | 46 | |
OlySolano | 0:1cb6019bbd61 | 47 | if (pulsador1==0){ |
OlySolano | 0:1cb6019bbd61 | 48 | horas++; |
OlySolano | 0:1cb6019bbd61 | 49 | } |
OlySolano | 0:1cb6019bbd61 | 50 | if (pulsador2==0){ |
OlySolano | 0:1cb6019bbd61 | 51 | minutos++; |
OlySolano | 0:1cb6019bbd61 | 52 | } |
OlySolano | 0:1cb6019bbd61 | 53 | } |
OlySolano | 0:1cb6019bbd61 | 54 | |
OlySolano | 0:1cb6019bbd61 | 55 | } |