Advertisement
Guest User

Untitled

a guest
May 2nd, 2024
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.48 KB | None | 0 0
  1. #include<Wire.h>
  2. #include<LiquidCrystal_I2C.h>
  3. #include"RTClib.h"
  4.  
  5. LiquidCrystal_I2C lcd(0x27, 16, 2);
  6. RTC_DS1307 rtc;
  7.  
  8. char dayOfTheWeek[7][12] = {"sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
  9. void time();
  10. void setup() {
  11.   Serial.begin(9600);
  12.   lcd.init();
  13.   lcd.backlight();
  14.  
  15.   if (!rtc.begin()) {
  16.     Serial.println("clount find rtc");
  17.     while (1);
  18.   }
  19.   if (! rtc.isrunning()) {
  20.     Serial.println("RTC is not running");
  21.   }
  22.   //rtc.adjust(DateTime(2024,5,2,6,58,0));
  23.   // Y   M D h m  s
  24.   //rtc.adjust(DateTime(F(__DATE__),F(__TIME__)));
  25. }
  26.  
  27. void loop() {
  28.   lcd.clear();
  29.   DateTime now = rtc.now();
  30.  
  31.   int Y = now.year();
  32.   int M = now.month();
  33.   int D = now.day();
  34.   int DW = now.dayOfTheWeek();
  35.   int h = now.hour();
  36.   int m = now.minute();
  37.   int s = now.second();
  38.   lcd.setCursor(0, 0);
  39.   lcd.print(h); lcd.print(":"); lcd.print(m); lcd.print("->"); lcd.print(dayOfTheWeek[DW]);
  40.   delay(100);
  41.   lcd.clear();
  42.   // Serial.print(Y); Serial.print("/");
  43.   // Serial.print(M); Serial.print("/");
  44.   // Serial.print(D); Serial.print("  ");
  45.   // Serial.println(dayOfTheWeek[DW]);
  46.   // Serial.print(h); Serial.print(":");
  47.   // Serial.print(m); Serial.print(":");
  48.   // Serial.println(s);
  49.   // delay(5000);
  50.  
  51.    
  52.   if (  h == 8 && m == 51 && s > 0 && s < 30)
  53.   {
  54.     lcd.setCursor(0, 0);
  55.     lcd.print(h); lcd.print(":"); lcd.print(m); lcd.print(dayOfTheWeek[DW]);
  56.     lcd.setCursor(0, 1);
  57.     lcd.print("take the medicine");
  58.     delay(100);
  59.   }
  60. }
  61.  
  62.  
  63.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement