ok lo e probado en el ejemplo lo e dejado asi y funciona
#include <Wire.h>
#include <Arduino.h>
#include <TimeLib.h>
#include <TimeAlarms.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x3F, 16, 2);
void setup()
{
Serial.begin(9600);
setTime(10,8,0,1,1,11); // Establece la hora y fecha 8:29:00am Jan 1 2011
// Crea las alarmas
Alarm.alarmRepeat(10,10,0, ApagoLCD); // Prueba // 23:00pm cada dia
Alarm.alarmRepeat(10,12,0,EnciendoLCD); // Prueba // 10:00am cada dia
Wire.begin();
lcd.begin();
}
void loop()
{
digitalClockDisplay();
Alarm.delay(1000); //espere un segundo entre la visualización del reloj
}
// funciones a llamar cuando se dispara una alarma:
void ApagoLCD(){
lcd.noBacklight();
Serial.println("Alarm: - LCD Apagado");
}
void EnciendoLCD(){
lcd.backlight();
Serial.println("Alarm: - LCD Encendido");
}
void digitalClockDisplay()
{
}
pero cuando trato de ponerlo me reclama
expected primary-expression before ') token
en la line 32
#include <Wire.h>
#include <Arduino.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x3F, 16, 2);
#include <OneWire.h> //temperatura
#include <DallasTemperature.h> //temperatura
#include "RTClib.h"
#include <TimeLib.h>
#include <TimeAlarms.h>
RTC_DS1307 rtc;//RTC_DS3231 RTC;
#define ONE_WIRE_BUS 12 //temperatura, pin de entrada
#define Pleds 4 //creamos la variable leds de 4 elementos **** prue1az4blan
int led[Pleds] = {6,9,10,11}; //creamos un vector para los pines a utilizar **** prue1az4blan
OneWire oneWire(ONE_WIRE_BUS); //temperatura
DallasTemperature sensors(&oneWire); //temperatura
float Celsius = 0; // car127 de esquema term lcd
void setup () {
Serial.begin(9600); // Establece la velocidad de datos del puerto serie
Wire.begin(); // Establece la velocidad de datos del bus I2C
sensors.begin(); //Temperatura
rtc.begin(); // Establece la velocidad de datos del RTC
// rtc.adjust(DateTime(__DATE__), (__TIME__));
// rtc.adjust(DateTime(2017, 11, 24, 22, 12, 0));
lcd.begin();
while (!Serial); // for Leonardo/Micro/Zero
// Crea las alarmas
setTime(10,8,0,1,1,11); // Establece la hora y fecha 8:29:00am Jan 1 2011
Alarm.alarmRepeat(23,00,0, ApagoLCD); // 23:00pm cada dia ApagoLCD
Alarm.alarmRepeat(10,00,0, EnciendoLCD); // 10:00am cada dia
}
void loop () {
/////// Apaga LCD y Enciende LCD /////////////
{
digitalClockDisplay();
Alarm.delay(1000); //espere un segundo entre la visualización del reloj
}
// funciones a llamar cuando se dispara una alarma:
void ApagoLCD(){
lcd.noBacklight();
Serial.println("Alarm: - LCD Apagado");
}
void EnciendoLCD(){
lcd.backlight();
Serial.println("Alarm: - LCD Encendido");
}
void digitalClockDisplay()
{
}
//int minute;
// int hour;
int tiempo;
DateTime now = rtc.now(); // Obtiene la fecha y hora del RTC
// ahora mostrar fecha y hora
lcd.clear();
//lcd.backlight();
lcd.setCursor(0,1);
lcd.print("Hora:");
lcd.print(" ");
if (now.hour() < 10) // si hora es menor a 10
{ // coloque un 0
lcd.print("0"); // y
} // se
lcd.print(now.hour(), DEC); // leera 08
lcd.print(":");
if (now.minute() < 10)
{
lcd.print("0");
}
lcd.print(now.minute(), DEC);
lcd.setCursor(0,0);
lcd.print("Fecha:");
lcd.print("");
lcd.print(now.day(), DEC);
lcd.print("/");
lcd.print(now.month(), DEC);
lcd.print("/");
lcd.print(now.year(), DEC);
// lcd.print(" ");
delay (3000); // Pausa 3 segundos
//lcd.noBacklight();
// delay (3000);
tiempo=(now.hour()*60)+now.minute(); // Para que sea un numero entero lo medimos en minutos
if (tiempo < 60)
{
tiempo=tiempo+1440; // para cuando sean las 12 de la noche (00 horas)
}
Luces (tiempo);
}
int Porcent(int Valor, int Maximo)
{
int result;
result = Valor * 100;
result = result / Maximo;
return result;
}
void Luces(int tiempo)
{
///////////tiempos de progamacion//////////
//conversion seria 60x11=660 la misma tabla para los demas parametros //
int PotAzul;
int InicioAmanecerAzul=660; //11:00
int FinAmanecerAzul=720; //12:00
int InicioAnochecerAzul=1260; //21:00
int FinAnochecerAzul=1380; //23:00
// int FinLuzLuna=1380; //23:00//
int MaxAzul=250; //Maximo que vamos a encender los LED sobre 255
int PorAzules;
int PotBLAN;
int InicioAmanecerLED=720; //12:00
int FinAmanecerLED=780; //13:00 //
int InicioAnochecerLED=1200; //20:00//
int FinAnochecerLED=1260; //21:00
int MaxLED=250; //Maximo que vamos a encender los LED sobre 255
int PorBLAN;
//////////////////// Azul ////////////////////////
//Noche
if (tiempo >FinAnochecerAzul || tiempo < InicioAmanecerAzul )
{
PotAzul=0;
Serial.println();
Serial.print("NOCHE AZUL: ");
Serial.println(PotAzul);
Serial.println();
}
//Amanecer
if (tiempo >= InicioAmanecerAzul && tiempo <= FinAmanecerAzul)
{
PotAzul=map(tiempo,InicioAmanecerAzul,FinAmanecerAzul,0,MaxAzul);
Serial.println();
Serial.print("AMANECIENDO AZUL: ");
Serial.println(PotAzul);
Serial.println();
}
//Dia
if (tiempo > FinAmanecerAzul && tiempo < InicioAnochecerAzul)
{
PotAzul=MaxAzul;
Serial.println();
Serial.print("DIA AZUL: ");
Serial.println(PotAzul);
Serial.println();
}
//Anochecer
if (tiempo >= InicioAnochecerAzul && tiempo <= FinAnochecerAzul)
{
PotAzul=map(tiempo,InicioAnochecerAzul,FinAnochecerAzul,MaxAzul,0);
Serial.println();
Serial.print("ANOCHECIENDO AZUL: ");
Serial.println(PotAzul);
Serial.println();
}
/////////////////// PotLED ///////////////////////
//Noche
if (tiempo >FinAnochecerLED || tiempo < InicioAmanecerLED )
{
PotBLAN=0;
}
//Amanecer
if (tiempo >= InicioAmanecerLED && tiempo <= FinAmanecerLED)
{
PotBLAN=map(tiempo,InicioAmanecerLED,FinAmanecerLED,0,MaxLED);
}
//Dia
if (tiempo > FinAmanecerLED && tiempo < InicioAnochecerLED)
{
PotBLAN=MaxLED;
}
//Anochecer
if (tiempo >= InicioAnochecerLED && tiempo <= FinAnochecerLED)
{
PotBLAN=map(tiempo,InicioAnochecerLED,FinAnochecerLED,MaxLED,0);
}
//////////////// PORCENTAJE LUZ/////////////////////
PorAzules = Porcent(PotAzul , 255);
PorBLAN = Porcent(PotBLAN , 255);
///// INOFORMACION EN PANTALLA LCD ////////
lcd.clear();
// lcd.backlight();
lcd.setCursor(0, 0);
if (tiempo >= InicioAmanecerAzul && tiempo <= FinAmanecerAzul)
lcd.print(" AMANECIENDO");
if (tiempo > FinAmanecerAzul && tiempo < InicioAnochecerAzul)
lcd.print(" DIA");
if (tiempo >= InicioAnochecerAzul && tiempo <= FinAnochecerAzul)
lcd.print(" ANOCHECER");
if (tiempo >FinAnochecerAzul || tiempo < InicioAmanecerAzul )
// PotAzul=map(tiempo,InicioAnochecerAzul,FinAnochecerAzul,MaxAzul,0);
lcd.print(" NOCHE ");
lcd.setCursor(2, 1);
lcd.print("Pot Luz");
// lcd.setCursor(0, 1);
// lcd.print("Pot BLAN");
lcd.setCursor(10, 1);
if (PorAzules < 10) lcd.print("0");
lcd.print(PorAzules);
lcd.print(" % ");
delay (3000); // Pausa 3 segundos
//Nombre proyecto
lcd.clear();
lcd.setCursor(2, 0);
lcd.print("PANTALLA LUZ");
lcd.setCursor(4, 1);
lcd.print("VER. 0.1");
delay (3000);
// Sensor Temperatura
sensors.requestTemperatures(); // Envia el comando para obtener temperatura
Celsius = sensors.getTempCByIndex(0);
lcd.clear();
lcd.setCursor(1, 0);
lcd.print("TEMP. ACUARIO: ");
lcd.setCursor(3, 1);
lcd.print(Celsius);
lcd.setCursor(10, 1);
lcd.print("\337C");
delay (3000);
//////////////// Declaracion de pines /////////////////
for (int i=0;i<Pleds;i++)
analogWrite(led[i],PotBLAN); // El pines del 6 al 9 seran de salida
analogWrite(5, PotAzul);
//analogWrite(9, PotLED);
//analogWrite(10, PotAzul);
delay(1000);
}