In this project we will see how to  display hour and date on a Crystal Liquid screen with Arduino. This project can be really useful to make an alarm clock or display hour and date. You just need to add batteries at your arduino card and print a box with a 3d printer to have a real clock.

Difficulty :

Necessary equipment

We will see the necessary equipment for this project:

  • 1 Arduino Uno card
  • 1 Screen LCD 16×2 Liquid Crystal
  • 1 Potentiometer
  • 1 resistor 220 ohms
  • bond wires (A dozen !)

Project scheme

Schéma horloge Arduino

Why we need a potentiometer?

The potentiometer is used to adjust the brightness of the Liquid Crystal screen. If you don’t want to use you can directly plug the brown wire to 5V and Ground to the first pin of the Liquid Crystal screen.

Project program

#include <LiquidCrystal.h> // Library for Crystal Liquid Screen

int hour_date[6] = {10,34,18,18,10,2022}; //second minute hour date month year
int mod[6] = {60,60,24,31,12,3000}; // incrementation limits 
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); // We initialize the pins of the Liquid crystal Screen 

void setup() {
  lcd.begin(16, 2); // We initialize the Liquid Screen with the right size 
}

void loop() {
  hour_date[0]++;//incrementation of the clock
    for (int i = 0; i < 6 ; i++){
      if (hour_date[i] == mod[i]) { // We verify if verification du dépassement de limite
        if (i<5) {hour_date[i+1] ++;}
        hour_date[i] = 0;
      }
    }
    lcd.setCursor(0,0); //On place le curseur sur la première ligne
    for (int j = 3; j < 5; j++) { //affichage de la date
      if (hour_date[j]<10){
        lcd.print("0");
        lcd.print(hour_date[j]);
      }
        else {lcd.print(hour_date[j]);}
      lcd.print("/");    
    }
    lcd.print(hour_date[5]); 
    lcd.setCursor(0,1); //On place le curseur sur la deuxième ligne
    for (int j = 2; j >= 0; j--) { //affichage de l'heure 
      if (hour_date[j]<10)
      {
        lcd.print ("0");
        lcd.print(hour_date[j]);
      }else {lcd.print(hour_date[j]);}
      if (j != 0){
        lcd.print(":"); 
      }   
    }
    delay(250);
}
 

Modify hour and date in the program!

As you can see in the picture,  the hour and date at the beginning is not at the right day. you can change it by yourself if you want.

To do that you have to modify this line in the program:

int hour_date[6] = {10,34,18,18,10,2022}; //second minute hour day month year 

How to maintain the actual hour when the Arduino is turn off?

As you may see, the clock and date is not maintained once the Arduino is turn off. It’s annoying when you want to do a clock for example. To fix that you can add to the project a RTC clock module (such as DS3231) which calculate the time even when the Arduino is turned off thanks to battery independent of the Arduino card.

Project simulation

Here is the project simulation on tinkercad: