Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save prasant1010/707c33462bd0affbfffb6cc9c6c579b2 to your computer and use it in GitHub Desktop.
Save prasant1010/707c33462bd0affbfffb6cc9c6c579b2 to your computer and use it in GitHub Desktop.
//created by prasant
//all right reserved to electronify.org
//you can copy edit or do what ever with this code
#include <Wire.h>
#include "RTClib.h"
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 13, 8, 9, 10, 11);
RTC_DS1307 RTC;
void setup () {
Wire.begin();
RTC.begin();
lcd.begin(20, 4);
pinMode(7,OUTPUT);
pinMode(6,OUTPUT);
// following line sets the RTC to the date & time this sketch was compiled
RTC.adjust(DateTime(__DATE__, __TIME__));
}
void loop () {
DateTime now = RTC.now();
lcd.setCursor(0, 0);
lcd.print(now.day(), DEC);
lcd.print('/');
lcd.print(now.month(), DEC);
lcd.print('/');
lcd.print(now.year(), DEC);
lcd.print(' ');
lcd.setCursor(0, 1);
if (now.hour()<10)
lcd.print('0');
lcd.print(now.hour(), DEC);
lcd.print(':');
if (now.minute()<10)
lcd.print('0');
lcd.print(now.minute(), DEC);
lcd.print(':');
if (now.second()<10)
lcd.print('0');
lcd.print(now.second(), DEC);
if ( ( now.hour() == 12 ) && ( now.minute() == 20 ) )
{
digitalWrite(7,HIGH);
lcd.setCursor(0, 2);
lcd.print("TM:12:20 MOTOR IS ON");
}
else
{
digitalWrite(7,LOW);
lcd.setCursor(0, 2);
lcd.print("MOTOR TM 12:20-12:21");
}
if ( ( now.hour() == 12 ) && ( now.minute() > 20 )&& ( now.minute() <= 25 ) )
{
digitalWrite(6,HIGH);
lcd.setCursor(0, 3);
lcd.print("TM :12:20 LAMP IS ON");
}
else
{
digitalWrite(6,LOW);
lcd.setCursor(0, 3);
lcd.print("LAMP TM 12:20-12:25");
}
delay(50);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment