MisterBotBreak
Published

How to Make a Simple Clock

This project will show you how to make a simple Clock using a RTC Clock and a LCD.

BeginnerFull instructions provided12 minutes27,477
How to Make a Simple Clock

Things used in this project

Hardware components

i2C LCD
×1
Arduino UNO
Arduino UNO
×1
RTC Clock
×1
Jumper wires (generic)
Jumper wires (generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Code

RTC Clock

Arduino
#include <Wire.h> 
#include <LiquidCrystal_I2C.h>
#include <ds3231.h>
 
struct ts t; 
LiquidCrystal_I2C lcd(0x27,20,4);  
void setup()
{
  lcd.init();
  lcd.backlight();
  
  Serial.begin(9600);
  Wire.begin();
  DS3231_init(DS3231_CONTROL_INTCN);
  t.hour=8; 
  t.min=30;
  t.sec=0;
  t.mday=23;
  t.mon=12;
  t.year=2019;
  DS3231_set(t); 
 
  if(t.hour<13){
    if(t.hour>0){
       lcd.setCursor(3,0);
       lcd.print("Good Morning !");
  
  }
  }
   if(t.hour<23){
    if(t.hour>19){
       lcd.setCursor(4,0);
       lcd.print("Good Night !");
    }
  }
   if(t.hour<20){
    if(t.hour>12){
       lcd.setCursor(2,0);
       lcd.print("Good Afternoon !");
    }
   }
  
  }


void loop(){ 
 DS3231_get(&t);

 lcd.setCursor(6,2);
 lcd.print(t.hour);
 lcd.setCursor(8,2);
 lcd.print(":");
 lcd.setCursor(9,2);
 lcd.print(t.min);
 lcd.setCursor(11,2);
 lcd.print(":");
 lcd.setCursor(12,2);
 lcd.print(t.sec);

 if(t.mon==1){
 lcd.setCursor(5,1);
 lcd.print("Jan ");
 }
  if(t.mon==2){
 lcd.setCursor(5,1);
 lcd.print("Feb ");
 }
  if(t.mon==3){
 lcd.setCursor(5,1);
 lcd.print("Mar ");
 }
   if(t.mon==4){
 lcd.setCursor(5,1);
 lcd.print("Apr ");
 }
  if(t.mon==5){
 lcd.setCursor(5,1);
 lcd.print("May ");
 }
   if(t.mon==6){
 lcd.setCursor(5,1);
 lcd.print("Jun ");
 }
   if(t.mon==7){
 lcd.setCursor(5,1);
 lcd.print("Jul ");
 }
   if(t.mon==8){
 lcd.setCursor(5,1);
 lcd.print("Aug ");
 }
   if(t.mon==9){
 lcd.setCursor(5,1);
 lcd.print("Sep ");
 }
   if(t.mon==10){
 lcd.setCursor(5,1);
 lcd.print("Oct ");
 }
   if(t.mon==11){
 lcd.setCursor(5,1);
 lcd.print("Nov ");
 }
   if(t.mon==12){
 lcd.setCursor(5,1);
 lcd.print("Dec ");
 }
 
 lcd.setCursor(9,1);
 lcd.print(t.mday);

 lcd.setCursor(12,1);
 lcd.print(t.year);

}

Credits

MisterBotBreak

MisterBotBreak

48 projects • 151 followers
I love electronics and cats :D !

Comments