chronodot RTC (DS3231) and nano

Hello,
i need some help in getting the DS3231 to actually do something =)
i got it working useing the example from the library.

but how can i use the time from the RTC to actually do something?
like: (i need some example code)
at 00:00 turn on LED
and 01:00 turn it off.
or 12:00 sound a alarm

all the examples and tutorials just show how to set it up. and i know that.

This library

Supports the DS3231 alarms and has alarm methods that you can call.

i get this far, i manage to grab the time from the RTC and print it to Serial.
but i don*t understand how i can use the time from the RTC to turn on a LED or something.
ive read the datasheet.

#include <DS3232RTC.h>
#include <Time.h>
#include <Wire.h>

void setup()
{
    Serial.begin(9600);
    setSyncProvider(RTC.get);
    if(timeStatus() != timeSet) 
        Serial.println("Unable to sync with the RTC");
    else
        Serial.println("RTC has set the system time");      
}
void loop()
{ 
    Serial.print(second());
    Serial.print(' ');
    Serial.print(minute());
    Serial.print(' ');
    Serial.print(hour());
    Serial.println();  
    delay(1000);
}

You appear to have misunderstood my reply. Please go and look at the alarm methods for that library on its page that I linked to.

mikki1211:
Hello,
i need some help in getting the DS3231 to actually do something =)
i got it working useing the example from the library.

but how can i use the time from the RTC to actually do something?
like: (i need some example code)
at 00:00 turn on LED
and 01:00 turn it off.
or 12:00 sound a alarm

all the examples and tutorials just show how to set it up. and i know that.

I hope this helps.
I haven't actually tested this code, so it might have bugs. But I think that this is what you need, more or less.

#include <DS3232RTC.h>
#include <Time.h>
#include <Wire.h>

int hh; // variable for the current hour
int old_hh; // the hour the previous time we checked
int mi; // variable for the current minute
int ss; // variable for the current second

void setup()
{
    Serial.begin(9600);
    setSyncProvider(RTC.get);
    if(timeStatus() != timeSet) {
        Serial.println("Unable to sync with the RTC");
    }
    else {
        Serial.println("RTC has set the system time");
    }
    
    // check the hour
    hh = hour();    
}
void loop()
{
    // remember the "old" hour (to know when the hour changes)
    old_hh = hh;
    
    // check what time it is now
    hh = hour();
    mi = minute();
    ss = second();
    
    // show the time in the Serial monitor
    Serial.print(hh);
    Serial.print(":");
    if (mi < 10) {
        // show minutes 0 through 9 as 00 through 09
        Serial.print("0");
    }
    Serial.print(mi);
    Serial.print(":");
    if (ss < 10) {
        // same deal as with the minutes
        Serial.print("0");
    }
    Serial.print(ss);
    Serial.println();
    
    if (hh != old_hh) {
        Serial.print("The hour has changed!!  New hour is: ");
        Serial.print(hh);
        Serial.println();
        
        // Now, depending on the new hour, we might need to do something. 
        
        if (hh == 0) {
          
            // If we're here, then the hour has just changed to 0.
            // Your code to turn on the LED should go here.
          
        }
        
        if (hh == 1) {
          
            // If we're here, then the hour has just changed to 1.
            // Your code to turn off the LED should go here.
          
        }
        
        if (hh == 12) {
          
            // If we're here, then the hour has just changed to 12.
            // Your code to sound the alarm should go here.
          
        }
    }
    
    delay(1000);
}