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.
Pushbutton
Arduino UNO
LCD Display (16 pin)
DS3231 RTC
Buzzer
Resistor (1000 Ohms)
Resistor (4700 Ohms)
Resistor (100 Ohms)
9V Battery
#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) {