DS1302 Data Extraction

I have programmed my Arduino to display the current time on a LCD. I would like to integrate this with a buzzer and lights to create an alarm. My approach it to read the time and compare it to an AlarmSetTime that I would choose. I was simply going to use an IF statement and digitalWrite HIGH to a pin when triggering the buzzer/lights when the date/time comparison was true. How do I read the time? Seems simple, but I keep getting compile errors. Here is my base code to display the time:

/*****************************************************

  • name:Real-time Clock Module
  • function:you can see the current date and time displayed on the I2C LCD1602.
    ******************************************************/
    //Email:support@sunfounder.com
    //Website:www.sunfounder.com

//include the libraries
#include <stdio.h>
#include <string.h>
#include <DS1302.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27, 16, 2); // set the LCD address to 0x27 for a 16 chars and 2 line display

uint8_t RST_PIN = 5; //RST pin attach to
uint8_t SDA_PIN = 6; //IO pin attach to
uint8_t SCL_PIN = 7; //clk Pin attach to
/* Create buffers */
char buf[50];
char day[10];

String comdata = "";
int numdata[7] = { 0 }, j = 0, mark = 0;
/* Create a DS1302 object */
DS1302 rtc(RST_PIN, SDA_PIN, SCL_PIN);//create a variable type of DS1302

void print_time()
{
/* Get the current time and date from the chip /
Time t = rtc.time();
/
Name the day of the week /
memset(day, 0, sizeof(day));
switch (t.day)
{
case 1:
strcpy(day, "Sun");
break;
case 2:
strcpy(day, "Mon");
break;
case 3:
strcpy(day, "Tue");
break;
case 4:
strcpy(day, "Wed");
break;
case 5:
strcpy(day, "Thu");
break;
case 6:
strcpy(day, "Fri");
break;
case 7:
strcpy(day, "Sat");
break;
}
/
Format the time and date and insert into the temporary buffer /
snprintf(buf, sizeof(buf), "%s %04d-%02d-%02d %02d:%02d:%02d", day, t.yr, t.mon, t.date, t.hr, t.min, t.sec);
/
Print the formatted string to serial so we can see the time */
Serial.println(buf);
lcd.setCursor(2, 0);
lcd.print(t.yr);
lcd.print("-");
lcd.print(t.mon / 10);
lcd.print(t.mon % 10);
lcd.print("-");
lcd.print(t.date / 10);
lcd.print(t.date % 10);
lcd.print(" ");
lcd.print(day);
lcd.setCursor(4, 1);
lcd.print(t.hr);
lcd.print(":");
lcd.print(t.min / 10);
lcd.print(t.min % 10);
lcd.print(":");
lcd.print(t.sec / 10);
lcd.print(t.sec % 10);
}

void setup()
{
Serial.begin(9600);
rtc.write_protect(false);
rtc.halt(false);
lcd.init(); //initialize the lcd
lcd.backlight(); //open the backlight
//Time t(2018, 4, 22, 17, 44, 00, 1);//initialize the time
/* Set the time and date on the chip */
//rtc.time(t);
}

void loop()
{

/add the data to comdata when the serial has data /
while (Serial.available() > 0)
{
comdata += char(Serial.read());
delay(2);
mark = 1;
}
/
Use a comma to separate the strings of comdata,
and then convert the results into numbers to be saved in the array numdata[] /
if (mark == 1)
{
Serial.print("You inputed : ");
Serial.println(comdata);
for (int i = 0; i < comdata.length(); i++)
{
if (comdata == ',' || comdata == 0x10 || comdata == 0x13)
_ {

* j++;
}
else*
* {
numdata[j] = numdata[j] * 10 + (comdata - '0');
}
}
/ The converted numdata add up to the time format, then write to DS1302*/

* Time t(numdata[0], numdata[1], numdata[2], numdata[3], numdata[4], numdata[5], numdata[6]);
rtc.time(t);
mark = 0;
j = 0;
/ clear comdata ,in order to wait for the next input /
comdata = String("");
/ clear numdata /
for (int i = 0; i < 7; i++) numdata = 0;
}
/ print the current time /_

print_time();
_ delay(1000);
}*_

(deleted)

It looks as though this line:

Time t = rtc.time();

near the start of the print_time() function is doing the actual reading of the time from the DS1302. You might want to look at the documentation for the Time class, and see if there are any other useful public functions, perhaps to help you with comparisons of Time objects.

If you want to know why you are getting compilation errors, it would be helpful if you showed us what the errors are. Also, it's a lot easier for people to read your code if if you use the "code" tags, as explained in the "How to use this forum" post at the top. See here:

How to use this forum

Here is the code:

/*****************************************************

  • name:Real-time Clock Module
  • function:you can see the current date and time displayed on the I2C LCD1602.
    ******************************************************/
    //Email:support@sunfounder.com
    //Website:www.sunfounder.com

//include the libraries
#include <stdio.h>
#include <string.h>
#include <DS1302.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27, 16, 2); // set the LCD address to 0x27 for a 16 chars and 2 line display

uint8_t RST_PIN = 5; //RST pin attach to
uint8_t SDA_PIN = 6; //IO pin attach to
uint8_t SCL_PIN = 7; //clk Pin attach to
/* Create buffers */
char buf[50];
char day[10];

String comdata = "";
int numdata[7] = { 0 }, j = 0, mark = 0;
/* Create a DS1302 object */
DS1302 rtc(RST_PIN, SDA_PIN, SCL_PIN);//create a variable type of DS1302

void print_time()
{
/* Get the current time and date from the chip /
Time t = rtc.time();
/
Name the day of the week /
memset(day, 0, sizeof(day));
switch (t.day)
{
case 1:
strcpy(day, "Sun");
break;
case 2:
strcpy(day, "Mon");
break;
case 3:
strcpy(day, "Tue");
break;
case 4:
strcpy(day, "Wed");
break;
case 5:
strcpy(day, "Thu");
break;
case 6:
strcpy(day, "Fri");
break;
case 7:
strcpy(day, "Sat");
break;
}
/
Format the time and date and insert into the temporary buffer /
snprintf(buf, sizeof(buf), "%s %04d-%02d-%02d %02d:%02d:%02d", day, t.yr, t.mon, t.date, t.hr, t.min, t.sec);
/
Print the formatted string to serial so we can see the time */
Serial.println(buf);
lcd.setCursor(2, 0);
lcd.print(t.yr);
lcd.print("-");
lcd.print(t.mon / 10);
lcd.print(t.mon % 10);
lcd.print("-");
lcd.print(t.date / 10);
lcd.print(t.date % 10);
lcd.print(" ");
lcd.print(day);
lcd.setCursor(4, 1);
lcd.print(t.hr);
lcd.print(":");
lcd.print(t.min / 10);
lcd.print(t.min % 10);
lcd.print(":");
lcd.print(t.sec / 10);
lcd.print(t.sec % 10);
}

void setup()
{
Serial.begin(9600);
rtc.write_protect(false);
rtc.halt(false);
lcd.init(); //initialize the lcd
lcd.backlight(); //open the backlight
//Time t(2018, 4, 22, 17, 44, 00, 1);//initialize the time
/* Set the time and date on the chip */
//rtc.time(t);
pinMode(8, OUTPUT);
}

void loop()
{

/add the data to comdata when the serial has data /
while (Serial.available() > 0)
{
comdata += char(Serial.read());
delay(2);
mark = 1;
}
/
Use a comma to separate the strings of comdata,
and then convert the results into numbers to be saved in the array numdata[] /
if (mark == 1)
{
Serial.print("You inputed : ");
Serial.println(comdata);
for (int i = 0; i < comdata.length(); i++)
{
if (comdata == ',' || comdata == 0x10 || comdata == 0x13)
_ {

* j++;
}
else*
* {
numdata[j] = numdata[j] * 10 + (comdata - '0');
}
}
/ The converted numdata add up to the time format, then write to DS1302*/

* Time t(numdata[0], numdata[1], numdata[2], numdata[3], numdata[4], numdata[5], numdata[6]);
rtc.time(t);
mark = 0;
j = 0;
/ clear comdata ,in order to wait for the next input /
comdata = String("");
/ clear numdata /
for (int i = 0; i < 7; i++) numdata = 0;
}
/ print the current time /_

print_time();
_ delay(1000);
if (Time t = (2018, 4, 22, 18, 07, 00, 1)) /this is the line where I would manually set the time I wish the alarm to trigger/
digitalWrite(8, HIGH);
}*

Here are the error messages:
Compiling 'Clock' for 'Arduino/Genuino Uno'_

Clock.ino: In function void loop()

Clock.ino: 140:42: error: conversion from 'int' to non-scalar type 'Time' requested
Error compiling project sources
* if (Time t = (2018, 4, 22, 18, 07, 00, 1))*
Build failed for project 'Clock'

Clock.ino: 140:43: error: could not convert 't' from 'Time' to 'bool
* if (Time t = (2018, 4, 22, 18, 07, 00, 1))*

Please use code tags when posting code. You can edit the post to add them ("</>" button).