Duda sobre setTime

Hola!!

Ando activo porque estoy full emocionado con este proyecto.

Tengo una duda sobre este código que encontré aqui y bueno adapté a mis necesidades, la duda es en la linea 21 donde dice " setTime(now.hour(), now.minute(), now.second(), now.month(), now.day(), now.year());" esta linea está seteandole la hora a mi reloj? la idea es que use la que ya tiene configurada pss, pero si la comento el código no me sirve, me da la duda es porque usa el setTime.

Lo siguiente es poder configurar las alarmas manualmente por teclado :slight_smile:

/** RTC Alarms without DS3231 without powering down */
#include <Wire.h>

#include <Time.h>
#include <TimeAlarms.h>
#include <LiquidCrystal_I2C.h>//libreria del lcd 16x2
#include "RTClib.h"
RTC_DS1307 rtc;

LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  // Set the LCD I2C address
 
void setup(){
 Serial.begin(9600);
 Wire.begin();
 rtc.begin();
 lcd.begin(16, 2);
 if (! rtc.isrunning()) {
 Serial.println("RTC is NOT running!");
 //rtc.adjust(DateTime(__DATE__, __TIME__));
 Serial.print("time set auto");
 }
  
  
 //setTime(8,29,0,1,1,11); // Fecha Saturday 8:29:00am Jan 1 2011
 DateTime now = rtc.now();
 setTime(now.hour(), now.minute(), now.second(), now.month(), now.day(), now.year());
 // create the alarms 
 // Crear alarmas 
 Alarm.alarmRepeat(12,44,0, MorningAlarm); // 8:00am every day
 Alarm.alarmRepeat(16,50,0,EveningAlarm); // 4:00pm every day 
 Alarm.alarmRepeat(17,05,0,EveningAlarm); // 1:00am every day 
 //Alarm.alarmRepeat(dowSaturday,8,30,30,WeeklyAlarm); // 8:30:30 every Saturday 
 //Alarm.timerRepeat(15, Repeats); // timer for every 15 seconds 
 //Alarm.timerOnce(10, OnceOnly); // called once after 10 seconds 
 Serial.print("Alarms listas!");
}
 
void loop(){ 
 digitalClockDisplay();
 
 imprimirFechayHoraenLCD();
 Alarm.delay(1000); // esperar 1 segundo entre displays
}
 
// Funciones de Alarma:
void MorningAlarm(){
 Serial.println("Alarm: - read CO/V & post to web"); 
 lcd.setCursor(0,0);
 lcd.print("Hora de Comer!");
 delay(2000);
 lcd.setCursor(0,1);
 lcd.print("Sirviendo comida");
 delay(3000);
 lcd.clear();
}
 
void EveningAlarm(){
 Serial.println("Alarm: - read CO/V & post to web"); 
}
 
void DawnAlarm(){
 Serial.println("Alarm: - read CO/V & post to web"); 
}
 
void WeeklyAlarm(){
 Serial.println("Alarm: - its Monday Morning"); 
}
 
void ExplicitAlarm(){
 Serial.println("Alarm: - this triggers only at the given date and time"); 
}
 
void Repeats(){
 Serial.println("15 second timer"); 
}
 
void OnceOnly(){
 Serial.println("This timer only triggers once"); 
}
 
void digitalClockDisplay()
{
 // digital clock display of the time
 Serial.print(hour());
 printDigits(minute());
 printDigits(second());
 Serial.println(); 
}

void imprimirFechayHoraenLCD()
{
  ////// Se imprimen los datos en una pantalla LCd 16x2  ///////
    DateTime now = rtc.now(); 
    lcd.setCursor(0,0);          // Se imprime en el primer renglon posicion 0,0
    lcd.print(char(1));          // Mostramos el caracter 1
    lcd.print(" ");              // Se imprimir un espacio
    printDigitsLcd(now.day());      // Se Imprime el dia
    lcd.print("/");              
    printDigitsLcd(now.month());    // Se Imprime el mes
    lcd.print("/");
    lcd.print(now.year());       // Se Imprime el año
    lcd.setCursor(0,1);          // Se Imprime en la segunda fila, caracter 1
    lcd.print(char(2));          // Display a hollow heart
    lcd.print(" ");
    lcd.print(now.hour());       // Se Imprime la hora
    lcd.print(":");
    printDigitsLcd(now.minute());   // Se Imprime los minutos
    lcd.print(":");
    printDigitsLcd(now.second());   // Se Imprime los segundos
    lcd.print("    ");
}
 
void printDigits(int digits)
{
 Serial.print(":");
 if(digits < 10)
 Serial.print('0');
 Serial.print(digits);
}

void printDigitsLcd(int digits){
  // funcion para añadir un cero a los digitos inferiores a 10
   if(digits < 10)
    lcd.print('0');
   lcd.print(digits);
 }

esta linea está seteandole la hora a mi reloj?

Si. Solo coméntala y listo.

Gracias!!

Tenias razón :smiley: