Ciao ragazzi, da qualche giorno ho ricevuto il mdulo RTC con DS1307 assemblato con quarzo e batteria tampone tipo questo :
Uploaded with ImageShack.us
l'ho collegato ad Arduino, caricato uno sketch per una prima prova e per settare l'ora e la data, tutto perfetto come un orologio svizzero
Allora incomincio a modificare lo sketch (che riporto sotto) per primo per evitare che ogni volta che lo ricarico mi vada a modificare i settaggi ho commentato i comandi per settare l'orologio e poi aggiungo un paio di righe di print su seriale (quelle con il commento in italiano ) ricarico tutto sull'Arduino e cosa mi succede ?
Nonostante abbia commentato le istruzioni per il settaggio ogni volta che riparte l'orologio si setta sui parametri impostato nello sketch e la stessa cosa lo fa se tolgo l'alimentazione e riaccendo il tutto dopo un pò, dove ho sbagliato ?
Ringrazio anticipatamente chi mi risponderà.
Ciao.
/*Reads the value from a Real Time Clock (RTC) DS1307 and displays it in the serial monitor
*
*Created by D. Sjunnesson 1scale1.com d.sjunnesson (at) 1scale1.com
*
*Created with combined information from
*http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1180908809
*http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1191209057
*
*
*Big credit to mattt (please contact me for a more correct name...) from the Arduino forum
*which has written the main part of the library which I have modified
*
*/#include <WProgram.h>
#include <Wire.h>
#include <DS1307.h> // written by mattt on the Arduino forum and modified by D. Sjunnessonvoid setup()
{
Serial.begin(9600);/*RTC.stop();
RTC.set(DS1307_SEC,1); //set the seconds
RTC.set(DS1307_MIN,31); //set the minutes
RTC.set(DS1307_HR,22); //set the hours
RTC.set(DS1307_DOW,3); //set the day of the week
RTC.set(DS1307_DATE,17); //set the date
RTC.set(DS1307_MTH,6); //set the month
RTC.set(DS1307_YR,10); //set the year
RTC.start();
*/
}void loop()
{Serial.print(" ORA "); // Etichetta
Serial.print(RTC.get(DS1307_HR,true)); //read the hour and also update all the values by pushing in true
Serial.print(":");
Serial.print(RTC.get(DS1307_MIN,false));//read minutes without update (false)
Serial.print(":");
Serial.print(RTC.get(DS1307_SEC,false));//read seconds
Serial.print(" DATA "); // Etichetta
Serial.print(RTC.get(DS1307_DATE,false));//read date
Serial.print("/");
Serial.print(RTC.get(DS1307_MTH,false));//read month
Serial.print("/");
Serial.print(RTC.get(DS1307_YR,false)); //read year
Serial.println();delay(1000);
}