ds1302 data reading problem,

hi all,

i am trying to make a daily alarm with arduino uno and ds1302 .I just started to work with RTC modules and i converted the basic example sketch coming with the library.I am trying to make alarm on every day 1 p.m .For testing my code i connected with led but the led is not getting on for the set time .pls guide me to get through the project .

my code is

// DS1302_Serial_Easy 
// Copyright (C)2015 Rinky-Dink Electronics, Henning Karlsen. All right reserved
// web: http://www.RinkyDinkElectronics.com/
//
// A quick demo of how to use my DS1302-library to 
// quickly send time and date information over a serial link
//
// I assume you know how to connect the DS1302.
// DS1302:  CE pin    -> Arduino Digital 2
//          I/O pin   -> Arduino Digital 3
//          SCLK pin  -> Arduino Digital 4

#include <DS1302.h>

// Init the DS1302
DS1302 rtc(2, 3, 4);
int ledpin =6;

void setup()
{
  // Set the clock to run-mode, and disable the write protection
  rtc.halt(false);
  rtc.writeProtect(false);
  
  // Setup Serial connection
  Serial.begin(9600);
  pinMode( ledpin,OUTPUT);
  digitalWrite(ledpin,LOW);
  

  // The following lines can be commented out to use the values already stored in the DS1302
  rtc.setDOW(THURSDAY);        // Set Day-of-Week to THURSDY
  //rtc.setTime(13, 28, 0);     // Set the time to 12:00:00 (24hr format)
  //rtc.setDate(7, 12, 2017);   // Set the date to DECEMBER 7th, 2017
}

void loop()
{
  // Send Day-of-Week
  Serial.print(rtc.getDOWStr());
  Serial.print(" ");
  
  // Send date
  Serial.print(rtc.getDateStr());
  Serial.print(" -- ");

  // Send time
  Serial.println(rtc.getTimeStr());
  
  // Wait one second before repeating :)
  delay (1000);
   if(rtc.getTimeStr()== 13,00,0){
    digitalWrite(ledpin,HIGH);
  }
  
}

Have you ever seen == being used if(rtc.getTimeStr() [color=red]== 13,00,0[/color]) that way? What does getTimeStr return? And how do you compare that with what you want? (also given you are waiting for 1 second if you are unlucky you might miss the exact second @13:00:00

i am a newbee and i am not familiar with RTC coding . can you suggest any reference area for the library to search similar projects and study the coding pattern.

This has nothing to do with RTC coding. This is pure basics of programming.

How do you compare things? How do you write strings or Strings...

Start by looking the documentation or code for rtc.getTimeStr() and see what type is returned. Then decide what you need to do to compare.

Also I would avoid any library using the String class...I use this RTClib and don’t use 130x families because of very poor ability to keep time (will shift heavily). Use a DS3231 for stability

i altered the cod , but still dont trigger the led

// DS1302_Serial_Easy 
// Copyright (C)2015 Rinky-Dink Electronics, Henning Karlsen. All right reserved
// web: http://www.RinkyDinkElectronics.com/
//
// A quick demo of how to use my DS1302-library to 
// quickly send time and date information over a serial link
//
// I assume you know how to connect the DS1302.
// DS1302:  CE pin    -> Arduino Digital 2
//          I/O pin   -> Arduino Digital 3
//          SCLK pin  -> Arduino Digital 4

#include <DS1302.h>
String Hour;
String Min;
String Sec;

// Init the DS1302
DS1302 rtc(2, 3, 4);
int ledpin =6;
Time t;


void setup()
{
  // Set the clock to run-mode, and disable the write protection
  rtc.halt(false);
  rtc.writeProtect(false);
  
  // Setup Serial connection
  Serial.begin(9600);
  pinMode( ledpin,OUTPUT);
  digitalWrite(ledpin,LOW);
  t=rtc.getTime();

  // The following lines can be commented out to use the values already stored in the DS1302
 // rtc.setDOW(THURSDAY);        // Set Day-of-Week to THURSDY
 // rtc.setTime(17, 00, 15);     // Set the time to 12:00:00 (24hr format)
 // rtc.setDate(7, 12, 2017);   // Set the date to DECEMBER 7th, 2017
}

void loop()
{
  Hour =t.hour;
  Min = t.min;
  Sec = t.sec;
  
  // Send Day-of-Week
  Serial.print(rtc.getDOWStr());
  Serial.print(" ");
  
  // Send date
  Serial.print(rtc.getDateStr());
  Serial.print(" -- ");

  // Send time
  Serial.println(rtc.getTimeStr());
  
  // Wait one second before repeating :)
 
   if((Hour==17 )&& (Min == 25) && (Sec == 01)){
    digitalWrite(ledpin,HIGH);
  }
   delay (1000);
}

Where are the t struct values (t.hour, t.min, t.sec) set?

as i am a beginner i dont understand the whole idea of this library ,i am including the library document.

DS1302.pdf (112 KB)

abhisheksuma:
i altered the cod , but still dont trigger the led

Why, just for the halibut?

Have you loaded the simple blink sketch and changed the pin to the one you are using, 6? That will verify the LED hardware connection. How is the LED connected? Are you using a current limiting resistor?

Have you looked for documentation at http://www.RinkyDinkElectronics.com/?