Displaying an Clock/Time on a LCD TFT screen with Arduino UNO

In this article, I will show you how to get an clock/time on a LCD TFT screen with Arduino!

Read the tutorial below or watch the youtube video.

Project materials:

Arduino UNO
Click here for the Amazon productlink
arduino-uno

TFT 1.17 inch LCD screen (A000096 Arduino)
Click here for the Amazon productlink

arduino-tft

Some wires

wires.jpg

Wiring Diagram:

arduino-wiring-diagram-youtube3

Arduino Code

Copy the code below & upload it to your Arduino.

// CreaTechWeb: Displaying an Clock on a TFT/LCD screen with arduino
// https://createchweb.com/displaying-an-clock-on-a-lcd-tft-screen-with-arduino-uno/

#include <SPI.h>
#include <TFT.h>
char TEXTE[5];
#define lcd_cs 10
#define dc     9
#define rst    8
TFT aTFT = TFT(lcd_cs,dc,rst);
int hh = 00;  //Set start time for hours  
int H = 00;   //Set start time for minutes
int N = 00;    //Set start time for seconds
void setup(){
  aTFT.begin();
  aTFT.background(255,255,255);
  aTFT.setTextSize(5);
  aTFT.stroke(181,230,29);
  String(hh).toCharArray(TEXTE,5);
  if (hh < 10) {
    aTFT.text(TEXTE,40,15);
    String(0).toCharArray(TEXTE,5);
    aTFT.text(TEXTE,10,15);
  }
  if (hh > 9) {
    aTFT.text(TEXTE,10,15);
  }
  aTFT.stroke(181,230,29);
  aTFT.text(":",60,15);
  aTFT.stroke(181,230,29);
  String(H).toCharArray(TEXTE,5);
     if (H < 10) {
    aTFT.text(TEXTE,110,15);
    String(0).toCharArray(TEXTE,5);
    aTFT.text(TEXTE,80,15);
  }
  if (H > 9) {
    aTFT.text(TEXTE,80,15);
  }     
}
void loop(){
  aTFT.setTextSize(6);
  aTFT.stroke(181,230,29);
  String(N).toCharArray(TEXTE,5);
  N++;
  aTFT.text(TEXTE,10,55);
  delay(930);
  aTFT.stroke(255,255,255);
  aTFT.text(TEXTE,10,55);
  if(N == 60){
    N=0;
    H++;
    aTFT.background(255,255,255);
    aTFT.setTextSize(5);
    aTFT.stroke(181,230,29);
    aTFT.text(":",60,15);
    aTFT.stroke(181,230,29);
    String(H).toCharArray(TEXTE,5);
     if (H < 10) {
    aTFT.text(TEXTE,110,15);
    String(0).toCharArray(TEXTE,5);
    aTFT.text(TEXTE,80,15);
  }
  if (H > 9) {
    aTFT.text(TEXTE,80,15);
  }     
  String(hh).toCharArray(TEXTE,5);
  if (hh < 10) {
    aTFT.text(TEXTE,40,15);
    String(0).toCharArray(TEXTE,5);
    aTFT.text(TEXTE,10,15);
  }
  if (hh > 9) {
    aTFT.text(TEXTE,10,15);
  }
  }
  if(H == 60){
    H=00;
    hh++;
    aTFT.background(255,255,255);
    aTFT.setTextSize(5);
    aTFT.stroke(181,230,29);
    aTFT.text(":",60,15);
    aTFT.stroke(181,230,29);

  String(H).toCharArray(TEXTE,5);
  if (H < 10) {
    aTFT.text(TEXTE,110,15);
    String(0).toCharArray(TEXTE,5);
    aTFT.text(TEXTE,80,15);
  }
  if (H > 9) {
    aTFT.text(TEXTE,80,15);
  }     
  String(hh).toCharArray(TEXTE,5);
  if (hh < 10) {
    aTFT.text(TEXTE,40,15);
    String(0).toCharArray(TEXTE,5);
    aTFT.text(TEXTE,10,15);
  }
  if (hh > 9) {
    aTFT.text(TEXTE,10,15);
  }
 }

 if(hh == 24){
    hh=00;
    aTFT.background(255,255,255);
    aTFT.setTextSize(5);
    aTFT.stroke(181,230,29);
    aTFT.text(":",60,15);
    aTFT.stroke(181,230,29);

   
  String(H).toCharArray(TEXTE,5);
  if (H < 10) {
    aTFT.text(TEXTE,110,15);
    String(0).toCharArray(TEXTE,5);
    aTFT.text(TEXTE,80,15);
  }
  if (H > 9) {
    aTFT.text(TEXTE,80,15);
  }     
  String(hh).toCharArray(TEXTE,5);

  if (hh < 10) {
    aTFT.text(TEXTE,40,15);
    String(0).toCharArray(TEXTE,5);
    aTFT.text(TEXTE,10,15);
  }
  if (hh > 9) {
    aTFT.text(TEXTE,10,15);
  }
 } 
  }   
    



 

End result

20161123_175649.jpg