Untitled
unknown
c_cpp
4 months ago
1.6 kB
2
Indexable
#include <Wire.h> #include "RTClib.h" #include <LiquidCrystal.h> RTC_DS3231 rtc; char daysOfTheWeek[7][4] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}; int Day; int Month; int Year; int Secs; int Minutes; int Hours; String dofweek; String myDate; String myTime; #define rs 12 #define en 11 #define d4 5 #define d5 4 #define d6 3 #define d7 2 LiquidCrystal lcd(12, 11, 5, 4, 3, 2); void setup() { Serial.begin(9600); lcd.begin(16, 2); delay(3000); if (!rtc.begin()) { Serial.println("Couldn't find RTC"); while (1); } if (rtc.lostPower()) { Serial.println("RTC lost power, setting the time!"); rtc.adjust(DateTime(F(__DATE__), F(__TIME__))); } lcd.clear(); lcd.setCursor(3, 0); lcd.print("Tech Trends"); lcd.setCursor(5, 1); lcd.print("Shameer"); delay(3000); lcd.clear(); } void loop() { DateTime now = rtc.now(); Day = now.day(); Month = now.month(); Year = now.year(); Secs = now.second(); Hours = now.hour(); Minutes = now.minute(); dofweek = daysOfTheWeek[now.dayOfTheWeek()]; myDate = dofweek + " " + String(Day) + "/" + String(Month) + "/" + String(Year); char buffer[9]; sprintf(buffer, "%02d:%02d:%02d", Hours, Minutes, Secs); myTime = String(buffer); Serial.println(dofweek); Serial.println(myDate); Serial.println(myTime); lcd.setCursor(0, 0); lcd.print(" "); lcd.setCursor(0, 0); lcd.print(myDate); lcd.setCursor(6, 1); lcd.print(" "); lcd.setCursor(6, 1); lcd.print(myTime); delay(1000); }
Editor is loading...
Leave a Comment