Guest User

Untitled

a guest
Jun 27th, 2021
91
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <DS3231.h>
  2. #include <Wire.h>
  3. #include <LiquidCrystal_I2C.h>
  4.  
  5. LiquidCrystal_I2C lcd(0x27,16,2);
  6.  
  7. int Relay = 4;
  8.  
  9. DS3231  rtc(SDA, SCL);
  10. Time t;
  11.  
  12. const int OnHour = 10;//SET RELAY ON TIMER
  13. const int OnMin = 51;
  14.  
  15.  
  16. void setup() {
  17.  
  18.   rtc.begin();
  19.   pinMode(Relay, OUTPUT);
  20.   digitalWrite(Relay, LOW);
  21.   lcd.clear();
  22.   lcd.begin(16,2);
  23.   lcd.init();                      
  24.   lcd.backlight();
  25.  
  26.    rtc.setDOW(FRIDAY);    
  27.   rtc.setTime(10, 50, 0);    //SET TIME
  28.   rtc.setDate(14,06,2019);
  29.  
  30.  
  31. }
  32.  
  33. void loop() {
  34.   t = rtc.getTime();
  35.   {
  36.     lcd.print(rtc.getDOWStr());
  37.    lcd.setCursor(0,1);
  38.   lcd.print(" ");
  39.  
  40.   }
  41.  
  42.   // Send date
  43.  
  44.   {
  45.     lcd.print(rtc.getDateStr());
  46.    lcd.setCursor(8,0);
  47.   lcd.print("");
  48.  
  49. }
  50. // Send time
  51.  
  52. {
  53. lcd.println(rtc.getTimeStr());
  54.    lcd.setCursor(0,0);
  55.   lcd.print(" ");
  56.  
  57. }
  58.  
  59.  
  60.   if(t.hour == OnHour && t.min == OnMin){
  61.     digitalWrite(Relay,HIGH);
  62.    
  63.     }
  64.    
  65.    
  66.    
  67. }
  68.  
RAW Paste Data