Skip to content
Permalink
4435a9949d
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
42 lines (32 sloc) 1.02 KB
#include <mbed.h>
#include "Rtc_Ds1307.h"
Rtc_Ds1307 rtc(I2C_SDA, I2C_SCL);
int main() {
printf("\n[Build] %s %s\n", __DATE__, __TIME__);
DigitalOut led(LED1);
// put your setup code here, to run once:
time_t localTime;
Rtc_Ds1307::Time_rtc rtcTime;
rtcTime.year=2023;
rtcTime.date=23;
rtcTime.mon=3;
rtcTime.hour=12;
rtcTime.min=30;
rtcTime.sec = 12;
rtc.setTime(rtcTime, true, false);
//getTime();
while(1) {
// put your main code here, to run repeatedly:
//Get the Local Time
localTime = time(NULL);
printf("Time as seconds since January 1, 1970 = %u\n", (unsigned int)localTime);
printf("Time as a basic string = %s\n", ctime(&localTime));
rtc.getTime(rtcTime);
printf("%d:%d:%d Year %d\n", rtcTime.hour, rtcTime.min, rtcTime.sec, rtcTime.year);
//printf("RTC as seconds since January 1, 1970 = %u\n", (unsigned int)rtcTime);
//printf("RTC as a basic string = %s\n", ctime(&rtcTime));
//getTime();
led = !led;
thread_sleep_for(10000);
}
}