Display date and time on LCD screen. Starting date and time are specified by user with matrix keyboard

Dependencies:   TextLCD mbed

main.cpp

Committer:
a00958821
Date:
2016-10-26
Revision:
0:143f7a718e66

File content as of revision 0:143f7a718e66:

#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;
    }