Simple Digital Clock Using Arduino Without RTC

In this post we are going to make 3 different digital clocks without RTC or Real Time Clock module.

We will be constructing 3 types of digital clocks:

  • One with I2C adapter for LCD display.
  • One without I2C adapter for LCD display .
  • The last one with NOKIA 5510 LCD display.

All three digital clocks will not sport a RTC module.

Digital Clock with I2C LCD Module (WITHOUT RTC)

Circuit Diagram:

Digital Clock without RTC
Digital Clock without RTC

Circuit description:

The circuit consists of an arduino (you can use any Arduino board), a LCD display with I2C adapter, two push buttons and that’s all. You can power this circuit with 5V USB adapter or from 9V power supply (9V to Vin pin and GND to GND).

What is IIC or I2C or “I square C” Adapter for LCD Display?

The I2C adapter is used for reducing wire usage, which makes the project construction easier.

Digital Clock LCD with I2C Module
Digital Clock LCD with I2C Module

The I2C adapter module connection: Vcc to 5V and GND to GND, A4 to SDA and A5 to SCL.

This module has 16 output pins and 4 input pins, the 16 pins are soldered directly at back of the LCD. Out of the four input pins two are Vcc and GND and other two are Serial Clock and Serial data pins.

The blue cube on back of the module is used for adjusting the contrast of the LCD with a tiny screw driver. A jumper on left of the module controls the backlight and removing it will disable the backlight, addition to this we can also control backlight with code.

Arduino has built-in voltage regulator to give 5V output for I2C adapter module, so you can power the circuit with 9V without any worry.

You can set time by long pressing hours and minutes push buttons.

You may interested: Analog Clock Using Servo motor and Arduino

Prototype Image:

Prototype - Digital Clock without RTC
Prototype – Digital Clock without RTC

NOTE: One fancy feature with this clock is that it will greet you with “Good Moring”, “Good Afternoon”, “Good Evening” and “Good Night” messages depending on the time, this feature exists in all clocks explained in this article.

Download this I2C_LiquidCrystal Library before compiling: Click Here.

Program code for the above clock circuit diagram: Code Verified

//-----www<electronics-project-hub>com------//
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
int h = 12;
int m = 0;
int s = 0;
int flag = 0;
int TIME = 0;
const int hs = A0;
const int ms = A1;
int state1 = 0;
int state2 = 0;
void setup()
{
  lcd.init();
  lcd.backlight();
  pinMode(hs, INPUT_PULLUP);
  pinMode(ms, INPUT_PULLUP);
}
void loop()
{
  lcd.setCursor(0, 0);
  s = s + 1;
  lcd.print("TIME:" );
  lcd.print(h);
  lcd.print(":");
  lcd.print(m);
  lcd.print(":");
  lcd.print(s);
  if (flag < 12) lcd.print(" AM");
  if (flag == 12) lcd.print(" PM");
  if (flag > 12) lcd.print(" PM");
  if (flag == 24) flag = 0;
  delay(1000);
  lcd.clear();
  if (s == 60)
  {
    s = 0;
    m = m + 1;
  }
  if (m == 60)
  {
    m = 0;
    h = h + 1;
    flag = flag + 1;
  }
  if (h == 13)
  {
    h = 1;
  }
  lcd.setCursor(0, 1);
  if (h <= 12 && flag < 12)
  {
    lcd.print("GOOD MORNING  ;)");
  }
  if (h == 12 || h == 1 || h == 2 || h == 3 && flag >= 12)
  {
    lcd.print("GOOD AFTERNOON:)");
  }
  if (h == 4 || h == 5 || h == 6 || h == 7 || h == 8 && flag > 12)
  {
    lcd.print("GOOD EVENING  :)");
  }
  if (h >= 9 && flag > 12)
  {
    lcd.print("GOOD NIGHT  :)");
  }
  state1 = digitalRead(hs);
  if (state1 == 0)
  {
    h = h + 1;
    flag = flag + 1;
    if (flag < 12) lcd.print(" AM");
    if (flag == 12) lcd.print(" PM");
    if (flag > 12) lcd.print(" PM");
    if (flag == 24) flag = 0;
    if (h == 13) h = 1;
  }
  state2 = digitalRead(ms);
  if (state2 == 0)
  {
    s = 0;
    m = m + 1;
  }
}
//-----www<electronics-project-hub>com------//

Digital Clock without RTC and without I2C module

Some beginners may prefer to use LCD display in traditional way i.e. connecting all the wires from LCD to Arduino and some may have difficulty in finding I2C module and some with some other reasons.

In this section we will construct the Digital Clock without RTC and without I2C module.

Circuit Diagram:

Arduino Digital Clock without RTC
Arduino Digital Clock without RTC

The circuit consists of couple of push buttons for time setting, a LCD, an Arduino board and one variable resistor for adjusting LCD contrast. The circuit can be powered by 5V via USB or with 9V supply.

You may interested: Analog Clock Using Servo motor and Arduino

Program code for the above clock circuit: Code verified

//----www<electronics-project-hub>com-----//
#include <LiquidCrystal.h>
const int rs = 12;
const int en = 11;
const int d4 = 5;
const int d5 = 4;
const int d6 = 3;
const int d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
int h = 12;
int m = 0;
int s = 0;
int flag = 0;
int TIME = 0;
const int hs = A0;
const int ms = A1;
int state1 = 0;
int state2 = 0;
void setup()
{
  lcd.begin(16, 2);
  pinMode(hs, INPUT_PULLUP);
  pinMode(ms, INPUT_PULLUP);
}
void loop()
{
  lcd.setCursor(0, 0);
  s = s + 1;
  lcd.print("TIME:" );
  lcd.print(h);
  lcd.print(":");
  lcd.print(m);
  lcd.print(":");
  lcd.print(s);
  if (flag < 12) lcd.print(" AM");
  if (flag == 12) lcd.print(" PM");
  if (flag > 12) lcd.print(" PM");
  if (flag == 24) flag = 0;
  delay(1000);
  lcd.clear();
  if (s == 60)
  {
    s = 0;
    m = m + 1;
  }
  if (m == 60)
  {
    m = 0;
    h = h + 1;
    flag = flag + 1;
  }
  if (h == 13)
  {
    h = 1;
  }
  lcd.setCursor(0, 1);
  if (h <= 12 && flag < 12)
  {
    lcd.print("GOOD MORNING  ;)");
  }
  if (h == 12 || h == 1 || h == 2 || h == 3 && flag >= 12)
  {
    lcd.print("GOOD AFTERNOON:)");
  }
  if (h == 4 || h == 5 || h == 6 || h == 7 || h == 8 && flag > 12)
  {
    lcd.print("GOOD EVENING  :)");
  }
  if (h >= 9 && flag > 12)
  {
    lcd.print("GOOD NIGHT  :)");
  }
  state1 = digitalRead(hs);
  if (state1 == 0)
  {
    h = h + 1;
    flag = flag + 1;
    if (flag < 12) lcd.print(" AM");
    if (flag == 12) lcd.print(" PM");
    if (flag > 12) lcd.print(" PM");
    if (flag == 24) flag = 0;
    if (h == 13) h = 1;
  }
  state2 = digitalRead(ms);
  if (state2 == 0)
  {
    s = 0;
    m = m + 1;
  }
}
//----www<electronics-project-hub>com-----//  

Digital Clock Using NOKIA 5510 Display without RTC

In this section we will construct a fancy little clock using NOKIA 5510 display without RTC module.

Now let’s take a look at the NOKIA 5510 LCD display.

You may interested: Analog Clock Using Servo motor and Arduino

Nokia 5510 Display
Nokia 5510 Display

The NOKIA 5510 can be purchased from popular E-commerce site or local electronics store, you need no to salvage one from an old Nokia phones.

Note: I2C module cannot be used with this NOKIA 5510 display.

Specifications of NOKIA 5510:

  • Operating voltage: 2.7 volt to 3.3 volt, 5V will kill the display.
  • Current consumption: 6mA
  • Display resolution: 84 x 48 pixels monochrome.
  • Communication Protocol: SPI

It can also be interfaced with many other microcontroller boards and single board computer like Raspberry pi. It can display low resolution bitmap images.

Circuit Diagram for Digital Clock Using NOKIA 5510:

Arduino Clock without RTC
Arduino Clock without RTC
Digital clock without RTC
Digital clock without RTC

Circuit description:

The circuit consists of a NOKIA 5510 display, an Arduino board, couple of push buttons for time setting.

The display should be powered from 3.3V from Arduino, if you want the back-light to be active, connect the back-light pin to 3.3V. Connection between Arduino and LCD is given in the circuit diagram.

Again, this circuit can be powered from 5V USB or from 9V power supply.

Download these two Library files before compiling code:

Link 1: Nokia 5510 Library, click here.

Link 2: GFX Library, click here.

Program code for Digital Clock Using NOKIA 5510: Code Verified

//----www<electronics-project-hub>com----//
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_PCD8544.h>
Adafruit_PCD8544 display = Adafruit_PCD8544(7, 6, 5, 4, 3);
int h = 12;
int m = 0;
int s = 0;
int flag = 0;
int TIME = 0;
const int hs = A0;
const int ms = A1;
int state1 = 0;
int state2 = 0;
void setup()
{
  display.begin();
  display.setContrast(40);
  display.clearDisplay();
  pinMode(hs, INPUT_PULLUP);
  pinMode(ms, INPUT_PULLUP);
}
void loop()
{
  display.setCursor(0, 0);
  display.setTextSize(2);
  s = s + 1;
  display.print(h);
  display.print(":");
  display.print(m);
  display.setTextSize(1);
  display.print(":");
  display.print(s);
  display.setTextSize(2);
  if (flag < 12)
  {
    display.setCursor(28, 16);
    display.print("AM");
    display.display();
  }
  if (flag == 12)
  {
    display.setCursor(28, 16);
    display.print("PM");
    display.display();
  }
  if (flag > 12)
  {
    display.setCursor(28, 16);
    display.print("PM");
    display.display();
  }
  if (flag == 24)
  {
    flag = 0;
  }
  delay(1000);
  display.clearDisplay();
  if (s == 60)
  {
    s = 0;
    m = m + 1;
  }
  if (m == 60)
  {
    m = 0;
    h = h + 1;
    flag = flag + 1;
  }
  if (h == 13)
  {
    h = 1;
  }
  display.setTextSize(1);
  if (h <= 12 && flag < 12)
  {
    display.setCursor(28, 32);
    display.print("GOOD");
    display.setCursor(18, 40);
    display.print("MORNING ;)");
  }
  else if (h == 12 || h == 1 || h == 2 || h == 3 && flag >= 12)
  {
    display.setCursor(28, 32);
    display.print("GOOD");
    display.setCursor(9, 40);
    display.print("AFTERNOON :)");
  }
  else if (h == 4 || h == 5 || h == 6 || h == 7 || h == 8 && flag > 12)
  {
    display.setCursor(28, 32);
    display.print("GOOD");
    display.setCursor(18, 40);
    display.print("EVENING :)");
  }
  else if (h >= 9 && flag > 12)
  {
    display.setCursor(28, 32);
    display.print("GOOD");
    display.setCursor(25, 40);
    display.print("NIGHT :)");
  }
  state1 = digitalRead(hs);
  if (state1 == 0)
  {
    h = h + 1;
    flag = flag + 1;
    if (flag < 12)
    {
      display.print(" AM");
    }
    if (flag == 12)
    {
      display.print(" PM");
    }
    if (flag > 12)
    {
      display.print(" PM");
    }
    if (flag == 24) 
    {
      flag = 0;
    }
    if (h == 13) 
    {
      h = 1;
    }
  }
  state2 = digitalRead(ms);
  if (state2 == 0)
  {
    s = 0;
    m = m + 1;
  }
}
//----www<electronics-project-hub>com----//    

Pros and Cons of Digital Clock without RTC Module:

Constructing a digital clock without RTC has some good and also bad sides.

The good side is that the circuit is super simple and any beginner can replicate one with ease.

The down side of the project is that you have to power the circuit uninterrupted; absence of power for a second will reset the clock to 12:00 AM.

Another down side of this RTC less clock is its accuracy. All three clocks can reduce accuracy as time progress; it may lose/gain few seconds per month.

Update: 

How to Make 7 Segment Digital Clock Without RTC: Click here.

In the above project link you will learn how to build a 7 segment clock using Arduino without RTC module.

Arduino 7 Segment Digital Clock
Arduino 7 Segment Digital Clock

You may interested: Analog Clock Using Servo motor and Arduino

If you have any questions regarding this project feel free to ask us in comment section, you can anticipate a guaranteed reply from us.