Can someone help me with my clock LCD?

<I, wanna add a way to make it so when specific times and/or dates hit, the msg on the LCD will change to something else other then time and change back at the end of the day?
E.G saying its someones birthday on someones date or etc>

//YWROBOT
//Compatible with the Arduino IDE 1.0
//Library version:1.1
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include "RTClib.h"

RTC_DS3231 rtc;

LiquidCrystal_I2C lcd(0x27,20,4); // set the LCD address to 0x27 for a 16 chars and 2 line display
char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};

void setup()
{
rtc.begin();
lcd.init(); // initialize the lcd
lcd.init();
// Print a message to the LCD.
lcd.backlight();
{
rtc.adjust(DateTime(F(DATE), F(TIME)));
}
#ifndef ESP8266
while (!Serial); // wait for serial port to connect. Needed for native USB
#endif

if (! rtc.begin()) {
Serial.println("Couldn't find RTC");
Serial.flush();
while (1) delay(10);
}
}
void loop(){

DateTime now = rtc.now();
lcd.setCursor(0,0);
lcd.print("Time: ");
lcd.print(now.hour(),DEC);
lcd.print(":");
lcd.print(now.minute(),DEC);

if(now.minute(),DEC > 10){
lcd.setCursor(8,0);
lcd.print("0");
lcd.print(now.minute(),DEC);
}
lcd.print(" o'Clock");

lcd.setCursor(0,1);
lcd.print("Date: ");
lcd.print(now.day(), DEC);
lcd.print('/');
lcd.print(now.month(), DEC);
lcd.print('/');
lcd.print(now.year(), DEC);

lcd.setCursor(0,3);
lcd.print("Temperature: ");
lcd.print(rtc.getTemperature());
lcd.print("C");

}

Welcome to the forum

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use code tags (the </> icon above the compose window) to make it easier to read and copy for examination

That's pretty easy. If you're not sure how to do it, operate a little more with the tutorials you can find on the Internet about display testing and RTC testing. Then, when you have more basic programming knowledge, make comparisons of dates and times and write on the display. It's more a matter of logical reasoning than programming difficulty.

That's easy. After the call to DateTime now = rtc.now(); you check the date. If it is one of the special dates, display the special message. If it is NOT one of the special dates, display the date and time. It would be slightly easier to move all of the "display date" stuff to a separate function by changing:

void loop()
{
  DateTime now = rtc.now();
  lcd.setCursor(0,0);
  lcd.print("Time: ");

to

void loop()
{
  DateTime now = rtc.now();

  displayDateAndTime(DateTime now);
}

void displayDateAndTime(DateTime now)
{
  lcd.setCursor(0,0);
  lcd.print("Time: ");

Ummm.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.