Digital Clock Using Arduino

Introduction

A Digital Clock is an electronic device that displays time in a numerical format (HH:MM:SS) using LEDs, LCDs, or 7-segment displays. It is more precise and easier to read compared to analog clocks.

This project demonstrates how to build a real-time digital clock using Arduino and a Real-Time Clock (RTC) module.


Objective of the Project

  • To display time digitally using Arduino.
  • To learn interfacing of RTC modules with microcontrollers.
  • To implement a reliable and accurate clock system.
  • To display hours, minutes, and seconds on an LCD or 7-segment display.

Working Principle

The Digital Clock works using a Real-Time Clock (RTC) module.

How It Works

  1. RTC module (DS1307 / DS3231) keeps track of the current time.
  2. Arduino reads time from the RTC module.
  3. Time is displayed on an LCD or 7-segment display.
  4. Clock updates every second automatically.

Components Required

  • Arduino Uno
  • RTC Module (DS1307 / DS3231)
  • 16×2 LCD Display (or 7-segment display)
  • Potentiometer (for LCD contrast, if using LCD)
  • Jumper Wires
  • Breadboard / PCB
  • 5V Power Supply

Circuit Diagram

Connections for RTC and LCD

RTC Module (DS3231 / DS1307):
SCL -> A5 (Arduino)
SDA -> A4 (Arduino)
VCC -> 5V
GND -> GND

16x2 LCD:
RS  -> D7
EN  -> D6
D4  -> D5
D5  -> D4
D6  -> D3
D7  -> D2
VCC -> 5V
GND -> GND
VO  -> Potentiometer middle pin

Arduino Code for Digital Clock

#include <Wire.h>
#include <RTClib.h>
#include <LiquidCrystal.h>

RTC_DS3231 rtc;
LiquidCrystal lcd(7, 6, 5, 4, 3, 2);

void setup() {
  lcd.begin(16, 2);
  Wire.begin();
  rtc.begin();

  if (!rtc.begin()) {
    lcd.print("RTC Not Found!");
    while (1);
  }
}

void loop() {
  DateTime now = rtc.now();

  lcd.setCursor(0, 0);
  lcd.print("Time: ");
  if (now.hour() < 10) lcd.print("0");
  lcd.print(now.hour());
  lcd.print(":");
  if (now.minute() < 10) lcd.print("0");
  lcd.print(now.minute());
  lcd.print(":");
  if (now.second() < 10) lcd.print("0");
  lcd.print(now.second());

  lcd.setCursor(0, 1);
  lcd.print("Date: ");
  lcd.print(now.day());
  lcd.print("/");
  lcd.print(now.month());
  lcd.print("/");
  lcd.print(now.year());

  delay(1000);
}

Code Explanation

  • RTClib library is used to interface the RTC module.
  • Arduino reads hours, minutes, and seconds from the RTC.
  • LiquidCrystal library displays time and date on the LCD.
  • Time updates every second automatically.

Advantages

  • Accurate timekeeping using RTC module
  • Easy to read digital format
  • Can display date along with time
  • Expandable with alarms or timers

Applications

  • Digital alarm clocks
  • Time display in schools/offices
  • Embedded systems and microcontroller projects
  • IoT-based smart clocks

Future Enhancements

  • Add alarm function
  • Bluetooth or Wi-Fi synchronization
  • 7-segment display for a compact clock
  • Voice-controlled time display

Conclusion

The Digital Clock using Arduino is a simple yet practical electronics project that demonstrates real-time tracking of hours, minutes, and seconds. It is highly useful for learning RTC interfacing, LCD programming, and embedded system design.

Leave a Reply

Shopping cart

0
image/svg+xml

No products in the cart.

Continue Shopping