Now I see what your problem is. Your code will not compile. You should have stated that in the beginning and included the entire error message. It is easy to do. There is a button (lower right of the IDE window) called "copy error message". Copy the error and paste into a post in code tags.
OK, I got it to compile, though I do not know if it will work right as I do not have the hardware to test.
/*
This code create a MENU structure on a 16x2 LCD screen.
Six (6) different screens are implemented, and you can travel
thru them by pressing a button on Arduino PIN 4. Each press
of the button advances one (1) screen.
Made by Clovis Fritzen in 05/06/2017
http://www.FritzenMaker.com
http://www.FritzenLab.com.br
*/
//Based on YWROBOT's LiquidCrystal_I2C library, Library version:1.1
//Also based on the Debounce.ino sketch that comes with Arduino IDE
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <RTClib.h>
uint8_t clock[8] = {0x0, 0xe, 0x15, 0x17, 0x11, 0xe, 0x0};
LiquidCrystal_I2C lcd(0x27, 16, 2); // set the LCD address to 0x27 for a 16 chars and 2 line display
RTC_DS1307 RTC;
int WhichScreen = 1; // This variable stores the current Screen number
boolean hasChanged = true;
const int buttonPin = 4; // the number of the pushbutton pin
int buttonState; // the current reading from the input pin
int lastButtonState = LOW; // the previous reading from the input pin
unsigned long lastDebounceTime = 0; // the last time the output pin was toggled
unsigned long debounceDelay = 50; // the debounce time; increase if the output flickers
void setup()
{
lcd.init();// initialize the lcd
lcd.backlight();
pinMode(buttonPin, INPUT);
lcd.createChar(2, clock);
Wire.begin();
RTC.begin();
RTC.adjust(DateTime(22, 4, 28, 11, 14, 9));
}
void loop()
{
if (hasChanged == true)
{
switch (WhichScreen)
{
case 1:
{
firstScreen();
}
break;
case 2:
{
secondScreen();
}
break;
case 3:
{
thirdScreen();
}
break;
case 4:
{
fourthScreen();
}
break;
case 5:
{
fifthScreen();
}
break;
case 0:
{
}
break;
}
}
//-------------------------------
// BEGIN of the switch debouncing code
int reading = digitalRead(buttonPin);
if (reading != lastButtonState)
{
// reset the debouncing timer
lastDebounceTime = millis();
}
if ((millis() - lastDebounceTime) > debounceDelay)
{
// whatever the reading is at, it's been there for longer
// than the debounce delay, so take it as the actual current state:
// if the button state has changed:
if (reading != buttonState)
{
buttonState = reading;
// only toggle the LED if the new button state is HIGH
if (buttonState == HIGH)
{
hasChanged = true;
WhichScreen++;
}
}
else
{
hasChanged = false;
}
}
lastButtonState = reading;
// END of the switch Debouncing code
// --------------------------------------
if (WhichScreen > 5)
{
WhichScreen = 1;
}
}
void firstScreen()
{
lcd.clear();
lcd.setCursor(0, 0); // Column, line
lcd.print("Date and Time");
lcd.setCursor(0, 1);
lcd.print(" ");
lcd.clear ();
DateTime now = RTC.now();
lcd.print(byte(2)); // fixed
lcd.print(" ");
lcd.print(now.hour(), DEC);
lcd.print(':');
lcd.print(now.minute(), DEC);
lcd.print(':');
lcd.print(now.second(), DEC);
lcd.setCursor(0, 1);
lcd.print(now.day(), DEC);
lcd.print('/');
lcd.print(now.month(), DEC);
lcd.print('/');
lcd.print(now.year(), DEC);
lcd.print(' ');
delay(1000);
}
void secondScreen()
{
lcd.clear();
lcd.setCursor(0, 0); // Column, line
lcd.print("M T W T F S S");
lcd.setCursor(0, 1);
lcd.print(" ");
}
void thirdScreen()
{
lcd.clear();
lcd.setCursor(0, 0); // Column, line
lcd.print("Frequency");
lcd.setCursor(0, 1);
lcd.print(" ");
}
void fourthScreen()
{
lcd.clear();
lcd.setCursor(0, 0); // Column, line
lcd.print("Duration");
lcd.setCursor(0, 1);
lcd.print("7 min");
}
void fifthScreen()
{
lcd.clear();
lcd.setCursor(0, 0); // Column, line
lcd.print("Set Date & Time");
lcd.setCursor(0, 1);
lcd.print("");
}
In this part of the code, the "Date and Time" will not show up because you write it to the display then right away clear the display. You may want to examine the code for any more mistakes like that.
void firstScreen()
{
lcd.clear();
lcd.setCursor(0, 0); // Column, line
lcd.print("Date and Time");
lcd.setCursor(0, 1);
lcd.print(" ");
lcd.clear ();
DateTime now = RTC.now();