Bonjour à vous
Je viens a vous en demandant grand aide, voila mon problème.
J'utilise pour un projet une horloge DS1307 I2C , mais le problème c'est que je n'arrive pas a faire en sorte de paramétrer l'heure et la date, j'ai chercher sur les forum rien ne marche ? comment puis-je faire ?
Je vous donne mon code pour vous donner un apriorisme de ce que j'ai fait.
// Let´s include the libraries needed for the skecth
#include <Wire.h>
#include "RTClib.h"
#include "rgb_lcd.h"
////////////////////////////////////////////////////////////////////////////////////////////////////
// VARIABLES GLOBALES //
////////////////////////////////////////////////////////////////////////////////////////////////////
//Let´s declare the variables needed for the sketch
int direccion = 0x48;
RTC_DS1307 rtc;
rgb_lcd lcd;
void setup()
{
lcd.begin(16, 2);
Serial.begin (9600);
//Initiate the Serial communication
Wire.begin(); // Enable the communication
//Let´s cpnfigure the sensor
Wire.beginTransmission(direccion); //Start the device
Wire.write(0xAC); //Write configuration command
Wire.write(0x02); //Continue conversion
Wire.endTransmission(); //Stop the device
Wire.beginTransmission(direccion); //Restart the device
Wire.write(0xEE); //Start temperature conversion command
Wire.endTransmission(); //Stop the device
lcd.begin(16,2);
Serial.begin (9600);
Wire.begin();
rtc.begin();
if (! rtc.isrunning())
{
Serial.println("RTC is NOT running");
rtc.adjust(DateTime(DATE,TIME));
}
}
////////////////////////////////////////////////////////////////////////////////////////////
// PRINCIPAL //
// //
////////////////////////////////////////////////////////////////////////////////////////////
void loop()
{
//Delay to separate the communication and the measuring
delay(100);
Wire.beginTransmission(0x48); //Start the device
Wire.write (0xAA); //Read temperature command
Wire.endTransmission(); //Stop the device
Wire.requestFrom(0x48,1); // We ask for a byte
//Make the conversion to Faranheit
lcd.clear();
DateTime now = rtc.now();
lcd.setCursor (0,0);
lcd.print(now.year(), DEC);
lcd.print('/');
lcd.print(now.month(), DEC);
lcd.print('/');
lcd.print(now.day(), DEC);
lcd.setCursor(0,1);
lcd.print(now.hour(), DEC);
lcd.print(':');
lcd.print(now.minute(), DEC);
lcd.print(':');
lcd.print(now.second(), DEC);
lcd.println();
///////////////////////////////////////////////////////////////////////////////////////
Serial.print(now.year(), DEC);
Serial.print("/");
Serial.print(now.month(), DEC);
Serial.print("/");
Serial.print(now.day(), DEC);
Serial.print("/");
Serial.print(now.hour(), DEC);
Serial.print("/");
Serial.print(now.minute(), DEC);
Serial.print("/");
Serial.print(now.second(), DEC);
Serial.print("/");
Serial.println();
}