Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino UNO-Based Real-Time Clock with Alarm and LCD Display

View and Edit Project In Cirkit DesignerImage of Arduino UNO-Based Real-Time Clock with Alarm and LCD Display

Circuit Documentation

Summary

This circuit is a real-time clock (RTC) with an alarm feature, utilizing an Arduino UNO microcontroller, a DS3231 RTC module, an LCD display, multiple pushbuttons, a buzzer, and resistors. The circuit allows the user to set the time and alarm, and displays the current time and temperature on the LCD. The buzzer sounds when the alarm goes off.

Component List

  1. Pushbutton

    • Description: A simple pushbutton used for user input.
    • Pins: Pin 1 (in), Pin 2 (in), Pin 3 (out), Pin 4 (out)
  2. Arduino UNO

    • Description: A microcontroller board based on the ATmega328P.
    • Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0, A1, A2, A3, A4, A5, SCL, SDA, AREF, D13, D12, D11, D10, D9, D8, D7, D6, D5, D4, D3, D2, D1, D0
  3. LCD Display (16 pin)

    • Description: A 16x2 character LCD display.
    • Pins: VSS, VDD, VO, RS, R_W, E, DB0, DB1, DB2, DB3, DB4, DB5, DB6, DB7, A, K
  4. DS3231 RTC

    • Description: A real-time clock module with temperature sensor.
    • Pins: 32K, SQW, SCL, SDA, VCC, GND
  5. Buzzer

    • Description: A simple buzzer for sound output.
    • Pins: PIN, GND
  6. Resistor (1000 Ohms)

    • Description: A resistor with a resistance of 1000 Ohms.
    • Pins: pin1, pin2
  7. Resistor (4700 Ohms)

    • Description: A resistor with a resistance of 4700 Ohms.
    • Pins: pin1, pin2
  8. Resistor (100 Ohms)

    • Description: A resistor with a resistance of 100 Ohms.
    • Pins: pin1, pin2
  9. 9V Battery

    • Description: A 9V battery for power supply.
    • Pins: -, +

Wiring Details

Pushbutton

Arduino UNO

LCD Display (16 pin)

DS3231 RTC

Buzzer

Resistors

9V Battery

Documented Code

Arduino UNO Code

#include <DS3231.h> // Memanggil RTC3231 Library
#include <Wire.h>  // i2C Conection Library
#include <LiquidCrystal.h> // Libraries
#include <EEPROM.h>

LiquidCrystal lcd(2, 3, 4, 5, 6, 7); // Arduino pins to lcd

#define bt_time   A0
#define bt_up     A1
#define bt_down   A2
#define bt_alarm  A3

#define buzzer 8

// Init DS3231
DS3231  rtc(SDA, SCL);

// Init a Time-data structure
Time  t; // pencacah string time()

int hh = 0, mm = 0, ss = 0, dd = 0, bb = 0, set_day;
int yy = 0;
String Day = "  ";

int AlarmHH  = 21, AlarmMM  = 22, AlarmSS  = 23, setMode = 0, setAlarm = 0, alarmMode=0;

int stop =0, mode=0, flag=0;

// Eeprom Store Variable
uint8_t HH;
uint8_t MM;

byte bell_symbol[8] = {
    B00100,
    B01110,
    B01110,
    B01110,
    B01110,
    B11111,
    B01000,
    B00100
};

byte thermometer_symbol[8] = {
    B00100,
    B01010,
    B01010,
    B01110,
    B01110,
    B11111,
    B11111,
    B01110
};

void setup() {
    // Setup Serial connection
    Serial.begin(9600);

    rtc.begin(); // memulai koneksi i2c dengan RTC

    pinMode(bt_time,  INPUT_PULLUP);
    pinMode(bt_up,    INPUT_PULLUP);
    pinMode(bt_down,  INPUT_PULLUP);
    pinMode(bt_alarm, INPUT_PULLUP);

    pinMode(buzzer, OUTPUT);

    lcd.createChar(1, thermometer_symbol);
    lcd.createChar(2, bell_symbol);

    lcd.begin(16, 2); // Configura lcd numero columnas y filas
    lcd.setCursor(0,0);  // Show "TIME" on the LCD

    lcd.setCursor (0,0);
    lcd.print(" Real Time Clock ");
    lcd.setCursor (0,1);
    lcd.print("   With Alarm ");
    delay (2000);
    lcd.clear();

    stop=EEPROM.read(50);
    if(stop==0) {  
    } else {
        WriteEeprom();
    }

    EEPROM.write(50,0); 

    ReadEeprom();
    // Set RTC Untuk Pertama kali
    // rtc.setDOW(2);     // Set Day-of-Week to SUNDAY
    // rtc.setTime (00, 9, 50); 
    // rtc.setDate(12, 11, 2017);  
}

void loop() {  
    t = rtc.getTime();
    Day = rtc.getDOWStr(1);

    if (setMode == 0) {