PitDS1302RTC
L'utilizzo del realt time clock DS1302RTC.
Prova del RTC
Cosa serve:
- DS1302RTC
- resistenza
- cavetti
Codice sorgente:
//=======================================================================================================//|
// //|
// Include files required for Program Function Begin //|
// //|
//=======================================================================================================//|
//|
#include "virtuabotixRTC.h" //|
//|
//=======================================================================================================//|
// //|
// Include files required for Program Function End //|
// //|
//=======================================================================================================//|
// inserire resistenza da 220 ohm sul pin dati
// http://forum.arduino.cc/index.php?topic=205996.0
// alimentare a 3.3 V
// Creation of the Real Time Clock Object
// CLK DAT RST
virtuabotixRTC myRTC(6, 7, 8);
void setup() {
Serial.begin(9600);
// Set the current date, and time in the following format:
// seconds, minutes, hours, day of the week, day of the month, month, year
// myRTC.setDS1302Time(00, 59, 23, 6, 10, 1, 2014);
// togliere in commento per aggiornare l'orario
// rimettere il commento per l'utilizzo normale
// myRTC.setDS1302Time(00, 28, 10, 6, 10, 2, 2018);
}
//=======================================================================================================//|
// //|
// Printout by accessing Single Element objects BEGIN //|
// //|
//=======================================================================================================//|
// //|
// This example utilizes the Serial.print function to access individual data elements, this allows for //|
// user defined output format. //|
// //|
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//|
void loop() { //|
// This allows for the update of variables for time or accessing the individual elements. //|
myRTC.updateTime(); //|
//|
// Start printing elements as individuals //|
Serial.print("Current Date / Time: "); //|
Serial.print(myRTC.dayofmonth); //|
Serial.print("/"); //|
Serial.print(myRTC.month); //|
Serial.print("/"); //|
Serial.print(myRTC.year); //|
Serial.print(" "); //|
Serial.print(myRTC.hours); //|
Serial.print(":"); //|
Serial.print(myRTC.minutes); //|
Serial.print(":"); //|
Serial.println(myRTC.seconds); //|
//|
// Delay so the program doesn't print non-stop //|
delay( 5000); //|
} //|
//|
//=======================================================================================================//|
// //|
// Printout using BUFFER objects BEGIN //|
// //|
//=======================================================================================================//|
Scarica tutto quello che serve:
ZappocoS, 10 febbraio 2018