- Timestamp:
- Mar 28, 2016, 2:09:46 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
rtos_arduino/trunk/arduino_lib/libraries/RTC/examples/RTC_simple/RTC_simple.ino
r136 r175 2 2 This sketch gives a simple demonstration of how to use RTC library. 3 3 The code sets date and time using internal structure and then print on serial date and time. Time representation is 12 hour mode 4 5 NOTE: for M0/M0 pro only you can select the oscillator source for count. 6 If you want to use a low power oscillator use rtc.begin(TIME_H12, LOW_POWER); function. 7 If you want to use a more accurate oscillator use rtc.begin(TIME_H12, HIGH_PRECISION); function. 4 8 **********************************************************************************************************************************************************/ 5 9 … … 17 21 18 22 //filling internal structure for time 19 rtc. local_time.hour = 10; //hour20 rtc. local_time.minute = 44; //minute21 rtc. local_time.second = 0; //second22 rtc. local_time.Tmode = ANTI_MERIDIAN;23 rtc.time.hour = 10; //hour 24 rtc.time.minute = 44; //minute 25 rtc.time.second = 0; //second 26 rtc.time.Tmode = ANTI_MERIDIAN; 23 27 24 28 //filling internal structure for date 25 rtc. local_date.day = 13; //day26 rtc. local_date.month = 8; //month27 rtc. local_date.year = 15; //year29 rtc.date.day = 13; //day 30 rtc.date.month = 8; //month 31 rtc.date.year = 15; //year 28 32 29 33 rtc.setTime(); //setting time … … 42 46 43 47 //printing date in format YYYY/MM/DD 44 Serial.print(rtc. local_date.year+2000); // year48 Serial.print(rtc.date.year+2000); // year 45 49 Serial.print('/'); 46 Serial.print(rtc. local_date.month); // month50 Serial.print(rtc.date.month); // month 47 51 Serial.print('/'); 48 Serial.print(rtc. local_date.day); // day52 Serial.print(rtc.date.day); // day 49 53 Serial.print(' '); 50 54 51 55 //printing time 52 Serial.print(rtc. local_time.hour); //hour56 Serial.print(rtc.time.hour); //hour 53 57 Serial.print(':'); 54 Serial.print(rtc. local_time.minute); //minute58 Serial.print(rtc.time.minute); //minute 55 59 Serial.print(':'); 56 Serial.print(rtc. local_time.second); //second60 Serial.print(rtc.time.second); //second 57 61 Serial.print (' '); 58 if(rtc. local_time.Tmode == ANTI_MERIDIAN) Serial.println("AM"); // print AM or PM62 if(rtc.time.Tmode == ANTI_MERIDIAN) Serial.println("AM"); // print AM or PM 59 63 else Serial.println("PM"); 60 64
Note:
See TracChangeset
for help on using the changeset viewer.