Rafael Mena
/
DisplayDateAndTime
Display date and time on LCD screen. Starting date and time are specified by user with matrix keyboard
Diff: main.cpp
- Revision:
- 0:143f7a718e66
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Oct 26 16:09:55 2016 +0000 @@ -0,0 +1,47 @@ +#include "mbed.h" +#include "TextLCD.h" + + +Timer timer; +Ticker ledOnOff; +TextLCD lcd(D2,D3,D4,D5,D6,D7); +DigitalOut led(D11); +int sec; +int min=59; +int hor=11; + +void calc(); +void ledBlink(); + +int main() { + led = 1; + ledOnOff.attach(ledBlink,1); + timer.start(); + while(1){ + sec = timer.read(); + if(sec>=59) + { + min=min+1; + timer.stop(); + timer.reset(); + timer.start(); + } + if(min==60) + { + hor=hor+1; + min=00; + } + if(hor==12) + { + hor=0; + } + lcd.cls(); + lcd.printf("%02d:%02d:%02d",hor,min,sec); + wait(1); + } + } + + void ledBlink() + { + led = !led; + } \ No newline at end of file