How to Choose the Perfect LCD Clock for Your Desk

DIY: Building a Custom Arduino LCD Clock

Overview

Build a simple, reliable LCD clock using an Arduino, a 16×2 LCD display, and a real-time clock (RTC) module. This project is suitable for beginners and can be customized with alarms, backlight control, or temperature display.

Parts you’ll need

  • Arduino Uno (or compatible board)
  • 16×2 LCD with I2C backpack (or standard 16×2 LCD + potentiometer + wiring)
  • DS3231 RTC module (more accurate than DS1307)
  • Jumper wires (male-to-female / male-to-male as needed)
  • Breadboard (optional for prototyping)
  • 5V power supply (USB or wall adapter)
  • Push buttons (2–3 for setting time/alarm)
  • Optional: buzzer, enclosure, RTC coin cell battery (usually included)

Wiring

  1. If using an I2C LCD:
    • Connect LCD SDA → Arduino A4 (Uno)
    • Connect LCD SCL → Arduino A5 (Uno)
    • Connect VCC → 5V, GND → GND
  2. Connect DS3231 RTC module:
    • SDA → A4, SCL → A5, VCC → 5V, GND → GND
  3. Push buttons: connect one side to digital pins (e.g., D2, D3), the other side to GND; use INPUT_PULLUP in code.
  4. Buzzer (optional): positive to a digital pin (e.g., D8) through a resistor, negative to GND.

Libraries to install

  • Wire (built-in)
  • LiquidCrystalI2C (for I2C LCD)
  • RTClib (by Adafruit)

Install via Arduino IDE: Sketch → Include Library → Manage Libraries.

Arduino code

cpp

#include #include #include LiquidCrystal_I2C lcd(0x27, 16, 2); // adjust address if needed RTC_DS3231 rtc;

const int setBtn = 2; // example button pins const int incBtn = 3; const int buzzer = 8;

void setup() { pinMode(setBtn, INPUT_PULLUP); pinMode(incBtn, INPUT_PULLUP); pinMode(buzzer, OUTPUT); lcd.init(); lcd.backlight(); Wire.begin(); if (!rtc.begin()) {

lcd.clear(); lcd.print("RTC not found"); while (1); 

} if (rtc.lostPower()) {

// Set to compile time; change as needed rtc.adjust(DateTime(F(__DATE__), F(__TIME__))); 

} }

void loop() { DateTime now = rtc.now(); char buf[17]; snprintf(buf, sizeof(buf), “%02d:%02d:%02d”, now.hour(), now.minute(), now.second()); lcd.setCursor(0, 0); lcd.print(“Time:”); lcd.setCursor(6, 0); lcd.print(buf); lcd.setCursor(0, 1); lcd.print(“Date:”); snprintf(buf, sizeof(buf), “%02d/%02d/%04d”, now.day(), now.month(), now.year()); lcd.setCursor(6, 1); lcd.print(buf); delay(200); // Simple button-based time set (expand as desired) if (digitalRead(setBtn) == LOW) {

setTimeMenu(); 

} }

void setTimeMenu() { DateTime now = rtc.now(); int hh = now.hour(); int mm = now.minute(); bool setting = true; while (setting) {

lcd.clear(); lcd.setCursor(0,0); lcd.print("Set Time:"); lcd.setCursor(0,1); char t[6]; snprintf(t, sizeof(t), "%02d:%02d", hh, mm); lcd.print(t); delay(200); if (digitalRead(incBtn) == LOW) {   mm++;   if (mm >= 60) { mm = 0; hh = (hh + 1) % 24; }   delay(200); } if (digitalRead(setBtn) == LOW) {   rtc.adjust(DateTime(now.year(), now.month(), now.day(), hh, mm, 0));   setting = false;   delay(300); } 

} }

Assembly and testing

  • Power the Arduino and confirm the LCD displays time.
  • Press the set button to enter time-set mode; use the increment button to adjust minutes/hours (expand for full setting).
  • Verify RTC keeps time after power loss

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *