Hola compañeros, necesito ayuda, me he hecho un arduino, para control de iluminación, temperatura del agua y ambiente, con una placa relés para que me active unos ventiladores. De momento empezar con eso, y más adelante ampliarlo. El dimeado de las luces me va perfecto, el problema me viene con las temperaturas que no le saco punta y ya no sé qué hacer. Los sensores son dallas temperature DS18B. Siempre me marca 85º, haga frio o haga calor, y el relé se activa pero no me cierra el contacto. No sé si el problema lo tengo en la programación, os pongo el código a ver que me decís que puede estar pasando, y puedo utilizar el arduino para más cosas y que no sea solo para las luces:
////////////////////////////////////////////////////////
//// DEFINICIONES DE PINS USADOS Y LIBRERIAS USADAS ////
////////////////////////////////////////////////////////
#include <Wire.h> //Libreria para el reloj
#define DS1307_I2C_ADDRESS 0x68
#include <LiquidCrystal_I2C.h> //Libreria para la pantalla 20x4
LiquidCrystal_I2C lcd(0x27,20,4);
#include <OneWire.h> //Libreria para temperatura
#include <DallasTemperature.h> //Otra libreria para temperatura
#define ONE_WIRE_BUS 9 // temperatura, pin de entrada el 9
OneWire oneWire(ONE_WIRE_BUS); // temperatura
DallasTemperature sensors(&oneWire);// temperatura
int pinFase1 = 5; // Primera fase en encenderse, ultima fase en apagarse AZULES
int pinFase2 = 6; // Ultima fase en encenderse, primera fase en apagarse BLANCOS
int pinFase3 = 10; // Segunda fase en encenderse, MIXTAS
int pinRele1 = 2; // Relé para ventiladores
int Retraso = 5000;
int Retraso3 =3000;
///////////////////////////////////////////////////////
/////////////////////////RELOJ/////////////////////////
///////////////////////////////////////////////////////
byte decToBcd(byte val)
{
return ( (val/10*16) + (val%10) );
}
byte bcdToDec(byte val)
{
return ( (val/16*10) + (val%16) );
}
byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
////////////////////////////////////////////////////////////////
///////////////////////// CONFIGURACION/////////////////////////
////////////////////////////////////////////////////////////////
void setup()
{
Wire.begin(); //RELOJ
lcd.init(); //LCD
Serial.begin(9600); //LCD
pinMode (pinFase1, OUTPUT);
pinMode (pinFase2, OUTPUT);
pinMode (pinFase3, OUTPUT);
pinMode (pinRele1, OUTPUT);
sensors.begin(); //Temperatura
lcd.backlight();
lcd.clear();
delay(Retraso);
delay(Retraso3);
}
//////////////////////////////////////////////////////////////////
///////////////////////// BUCLE PRINCIPAL ////////////////////////
//////////////////////////////////////////////////////////////////
void loop ()
{
getDateDs1307(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year); // LEEMOS LA HORA
sensors.requestTemperatures();
Luces(minute, hour);
lcd.clear();
}
/////////////////////////////////////////////////////////////////////////
///////////////////////// FUNCIONES PRINCIPALES /////////////////////////
/////////////////////////////////////////////////////////////////////////
//////////////////////////// PORCENTAJE ////////////////////////////////
int Porcent(int Valor, int Maximo)
{
int result;
result=Valor*50;
result=result/Maximo;
return result;
}
void Luces(int minutos, int horas) {
int LucesAzules;
int InicioAmanecerAzul=900; //Amanece azules a las 15 horas
int FinAmanecerAzul=930; // Termina amanecer azules a las 15 y 30 minutos
int InicioAnochecerAzul=1411; // Empieza a anochecer azules a las 23 y 30 minutos
int FinAnochecerAzul=1440; // Se apagan los azules a las 24 horas
int MaxAzul=255;
int PorcentAzules;
int PasoAzulAM=MaxAzul/(FinAmanecerAzul-InicioAmanecerAzul);
int PasoAzulPM=MaxAzul/(FinAnochecerAzul-InicioAnochecerAzul);
int LucesMixtas;
int InicioAmanecerMixtas=931; //Empiezan Mixtas a las 15 y 30 horas
int FinAmanecerMixtas=960; // Terminan Mixtas a las 16:00
int InicioAnochecerMixtas=1380; //Empieza anochecer Mixtas a las 23:00
int FinAnochecerMixtas=1410; // Terminan anochecer Mixtas a las 23:30 horas
int MaxMixtas=255;
int PorcentMixtas;
int PasoMixtasAM=MaxMixtas/(FinAmanecerMixtas-InicioAmanecerMixtas);
int PasoMixtasPM=MaxMixtas/(FinAnochecerMixtas-InicioAnochecerMixtas);
int LucesBlancas;
int InicioAmanecerBlancas=961; // empieza amanecer blancas a las 16:00
int FinAmanecerBlancas=990; // Termina amanecer blancas a las 16:30 horas
int InicioAnochecerBlancas=1350; //Empieza atardecer blancas a las 22:30 horas
int FinAnochecerBlancas=1379;// Termina atardecer blancas a las 23:00
int MaxBlancas=255;
int PorcentBlancas;
int PasoBlancasAM=MaxBlancas/(FinAmanecerBlancas-InicioAmanecerBlancas);
int PasoBlancasPM=MaxBlancas/(FinAnochecerBlancas-InicioAnochecerBlancas);
int Tiempo;
Tiempo=horas*60+minutos;
//################################# AZULES ###################################
//Noche
if (Tiempo < InicioAmanecerAzul)LucesAzules=0;
//Amanecer
if (Tiempo >= InicioAmanecerAzul && Tiempo <= FinAmanecerAzul) LucesAzules=(Tiempo-InicioAmanecerAzul)*PasoAzulAM;
//Dia
if (Tiempo > FinAmanecerAzul && Tiempo < InicioAnochecerAzul) LucesAzules=MaxAzul;
//Anochecer
if (Tiempo >= InicioAnochecerAzul && Tiempo <= FinAnochecerAzul) LucesAzules=(FinAnochecerAzul-Tiempo)*PasoAzulPM;
//Control
if( LucesAzules <0) LucesAzules=0;
if( LucesAzules >MaxAzul) LucesAzules=MaxAzul;
//################################# MIXTAS ###################################
//Noche
if (Tiempo < InicioAmanecerMixtas) LucesMixtas=0;
//Amanecer
if (Tiempo >= InicioAmanecerMixtas && Tiempo <= FinAmanecerMixtas) LucesMixtas=(Tiempo-InicioAmanecerMixtas)*PasoMixtasAM;
//Dia
if (Tiempo > FinAmanecerMixtas && Tiempo < InicioAnochecerMixtas) LucesMixtas=MaxMixtas;
//Anochecer
if (Tiempo >= InicioAnochecerMixtas && Tiempo <= FinAnochecerMixtas) LucesMixtas=(FinAnochecerMixtas-Tiempo)*PasoMixtasPM;
//Control
if( LucesMixtas <0) LucesMixtas=0;
if( LucesMixtas >MaxMixtas) LucesMixtas=MaxMixtas;
//################################# BLANCAS ###################################
//Noche
if (Tiempo < InicioAmanecerBlancas) LucesBlancas=0;
//Amanecer
if (Tiempo >= InicioAmanecerBlancas && Tiempo <= FinAmanecerBlancas) LucesBlancas=(Tiempo-InicioAmanecerBlancas)*PasoBlancasAM;
//Dia
if (Tiempo > FinAmanecerBlancas && Tiempo < InicioAnochecerBlancas) LucesBlancas=MaxBlancas;
//Anochecer
if (Tiempo >= InicioAnochecerBlancas && Tiempo <= FinAnochecerBlancas) LucesBlancas=(FinAnochecerBlancas-Tiempo)*PasoBlancasPM;
//Control
if( LucesBlancas <0) LucesBlancas=0;
if( LucesBlancas >MaxBlancas) LucesBlancas=MaxBlancas;
analogWrite(pinFase1, LucesAzules);
analogWrite(pinFase2, LucesBlancas);
analogWrite(pinFase3, LucesMixtas);
PorcentAzules=Porcent(LucesAzules,255)*2;
PorcentBlancas=Porcent(LucesBlancas,255)*2;
PorcentMixtas=Porcent(LucesMixtas,255)*2;
/////////////////////////////////////////////////////
////////////// INOFORMACION EN PANTALLA LCD//////////
/////////////////////////////////////////////////////
lcd.clear();
lcd.setCursor(1,0);
lcd.print("CONTROL DE ACUARIO"); //////////////PRIMERA PANTALLA//////////////
lcd.setCursor(0,1);
lcd.print("====================");
lcd.setCursor(0,3);
if (dayOfMonth < 10) lcd.print("0");
lcd.print(dayOfMonth, DEC);
lcd.print("/");
if (month < 10) lcd.print("0");
lcd.print(month, DEC);
lcd.print("/");
if (year < 10) lcd.print("0");
lcd.setCursor(6,3);
lcd.print("20");
lcd.print(year, DEC);
lcd.setCursor(12,2);
lcd.print("Hora");
lcd.setCursor(12,3);
if (hour < 10) lcd.print("0");
lcd.print(hour, DEC);
lcd.print(":");
if (minute < 10) lcd.print("0");
lcd.print(minute, DEC);
lcd.print(":");
if (second < 10) lcd.print("0");
lcd.print(second, DEC);
lcd.setCursor(0,2);
switch (dayOfWeek)
{
case 1:
lcd.print("Lunes");
break;
case 2:
lcd.print("Martes");
break;
case 3:
lcd.print("Miercoles");
break;
case 4:
lcd.print("Jueves");
break;
case 5:
lcd.print("Viernes");
break;
case 6:
lcd.print("Sabado");
break;
case 7:
lcd.print("Domingo");
break;
}
delay(Retraso);
lcd.clear();
lcd.setCursor(4,0);
lcd.print("ILUMINACION");/////////////////////SEGUNDA PANTALLA - INFORMACION FASE AZULES////////////////////
lcd.setCursor(0,1);
lcd.print ("====================");
lcd.setCursor(0,3);
lcd.print("Fase Azules ");
if (PorcentAzules < 100) lcd.print(" ");
lcd.print(PorcentAzules);
lcd.print("%");
lcd.setCursor(0,2);
if (Tiempo > InicioAmanecerAzul && Tiempo < FinAmanecerMixtas) lcd.print (" AMANECIENDO ");
if (Tiempo > FinAmanecerMixtas && Tiempo < InicioAnochecerMixtas) lcd.print (" LUCE EL SOL ");
if (Tiempo >= InicioAnochecerMixtas && Tiempo <= FinAnochecerAzul) lcd.print (" ANOCHECIENDO ");
if (Tiempo > FinAnochecerAzul || Tiempo < InicioAmanecerAzul) lcd.print (" NOCHE ");
delay(Retraso);
lcd.clear();
lcd.setCursor(4,0);
lcd.print("ILUMINACION");/////////////////////TERCERA PANTALLA - INFORMACION FASE BLANCOS////////////////////
lcd.setCursor(0,1);
lcd.print ("====================");
lcd.setCursor(0,3);
lcd.print("Blanco Medio ");
if (PorcentAzules < 100) lcd.print(" ");
lcd.print(PorcentBlancas);
lcd.print("%");
lcd.setCursor(0,2);
if (Tiempo > InicioAmanecerAzul && Tiempo < FinAmanecerMixtas) lcd.print (" AMANECIENDO ");
if (Tiempo > FinAmanecerMixtas && Tiempo < InicioAnochecerMixtas) lcd.print (" LUCE EL SOL ");
if (Tiempo >= InicioAnochecerMixtas && Tiempo <= FinAnochecerAzul) lcd.print (" ANOCHECIENDO ");
if (Tiempo > FinAnochecerAzul || Tiempo < InicioAmanecerAzul) lcd.print (" NOCHE ");
delay(Retraso);
lcd.clear();
lcd.setCursor(4,0);
lcd.print("ILUMINACION");/////////////////////CUARTA PANTALLA - INFORMACION FASE BLANCO TOTAL////////////////////
lcd.setCursor(0,1);
lcd.print ("====================");
lcd.setCursor(0,3);
lcd.print("Blanco Total ");
if (PorcentAzules < 100) lcd.print(" ");
lcd.print(PorcentMixtas);
lcd.print("%");
lcd.setCursor(0,2);
if (Tiempo > InicioAmanecerAzul && Tiempo < FinAmanecerMixtas) lcd.print (" AMANECIENDO ");
if (Tiempo > FinAmanecerMixtas && Tiempo < InicioAnochecerMixtas) lcd.print (" LUCE EL SOL ");
if (Tiempo >= InicioAnochecerMixtas && Tiempo <= FinAnochecerAzul) lcd.print (" ANOCHECIENDO ");
if (Tiempo > FinAnochecerAzul || Tiempo < InicioAmanecerAzul) lcd.print (" NOCHE ");
delay(Retraso);
lcd.clear();
lcd.setCursor(4,0);
lcd.print("TEMPERATURA");///////////////////////CUARTA PANTALLA - TEMPERATURA//////////////////////////
lcd.setCursor(0,1);
lcd.print("====================");
lcd.setCursor(0,2);
lcd.print("AGUA ");
sensors.requestTemperatures();
lcd.print(sensors.getTempCByIndex(1),1);
lcd.setCursor(17,2);
if (sensors.getTempCByIndex(1)>=27.00){ //////////ENCENDEMOS VENTILADOR PANTALLA/////////////////
lcd.print("ON");
digitalWrite(pinRele1, LOW);}
else if (sensors.getTempCByIndex(1)<25.00){
lcd.print("OFF");
digitalWrite(pinRele1, HIGH);}
lcd.setCursor(13,2);
lcd.print("\337C");
lcd.setCursor(0,3);
lcd.print("AMBIENTE ");
sensors.requestTemperatures();
lcd.print(sensors.getTempCByIndex(0),1);
lcd.setCursor(16,3);
lcd.print("\337C");
delay(Retraso3);
}
////////////////////////////////////////////////////////////////////////
///////////////////////// FUNCIONES AUXILIARES /////////////////////////
////////////////////////////////////////////////////////////////////////
// Establece la fecha y el tiempo del ds1307
void getDateDs1307(byte *second,
byte *minute,
byte *hour,
byte *dayOfWeek,
byte *dayOfMonth,
byte *month,
byte *year)
{
// Resetea el registro puntero
Wire.beginTransmission(DS1307_I2C_ADDRESS);
Wire.send(0);
Wire.endTransmission();
Wire.requestFrom(DS1307_I2C_ADDRESS, 7);
// Alguno de estos necesitan enmascarar porque ciertos bits son bits de control
*second = bcdToDec(Wire.receive() & 0x7f);
*minute = bcdToDec(Wire.receive());
*hour = bcdToDec(Wire.receive() & 0x3f); // Need to change this if 12 hour am/pm
*dayOfWeek = bcdToDec(Wire.receive());
*dayOfMonth = bcdToDec(Wire.receive());
*month = bcdToDec(Wire.receive());
*year = bcdToDec(Wire.receive());
}
////////////////////////////////////////////////////////
//// DEFINICIONES DE PINS USADOS Y LIBRERIAS USADAS ////
////////////////////////////////////////////////////////
#include <Wire.h> //Libreria para el reloj
#define DS1307_I2C_ADDRESS 0x68
#include <LiquidCrystal_I2C.h> //Libreria para la pantalla 20x4
LiquidCrystal_I2C lcd(0x27,20,4);
#include <OneWire.h> //Libreria para temperatura
#include <DallasTemperature.h> //Otra libreria para temperatura
#define ONE_WIRE_BUS 9 // temperatura, pin de entrada el 9
OneWire oneWire(ONE_WIRE_BUS); // temperatura
DallasTemperature sensors(&oneWire);// temperatura
int pinFase1 = 5; // Primera fase en encenderse, ultima fase en apagarse AZULES
int pinFase2 = 6; // Ultima fase en encenderse, primera fase en apagarse BLANCOS
int pinFase3 = 10; // Segunda fase en encenderse, MIXTAS
int pinRele1 = 2; // Relé para ventiladores
int Retraso = 5000;
int Retraso3 =3000;
///////////////////////////////////////////////////////
/////////////////////////RELOJ/////////////////////////
///////////////////////////////////////////////////////
byte decToBcd(byte val)
{
return ( (val/10*16) + (val%10) );
}
byte bcdToDec(byte val)
{
return ( (val/16*10) + (val%16) );
}
byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
////////////////////////////////////////////////////////////////
///////////////////////// CONFIGURACION/////////////////////////
////////////////////////////////////////////////////////////////
void setup()
{
Wire.begin(); //RELOJ
lcd.init(); //LCD
Serial.begin(9600); //LCD
pinMode (pinFase1, OUTPUT);
pinMode (pinFase2, OUTPUT);
pinMode (pinFase3, OUTPUT);
pinMode (pinRele1, OUTPUT);
sensors.begin(); //Temperatura
lcd.backlight();
lcd.clear();
delay(Retraso);
delay(Retraso3);
}
//////////////////////////////////////////////////////////////////
///////////////////////// BUCLE PRINCIPAL ////////////////////////
//////////////////////////////////////////////////////////////////
void loop ()
{
getDateDs1307(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year); // LEEMOS LA HORA
sensors.requestTemperatures();
Luces(minute, hour);
lcd.clear();
}
/////////////////////////////////////////////////////////////////////////
///////////////////////// FUNCIONES PRINCIPALES /////////////////////////
/////////////////////////////////////////////////////////////////////////
//////////////////////////// PORCENTAJE ////////////////////////////////
int Porcent(int Valor, int Maximo)
{
int result;
result=Valor*50;
result=result/Maximo;
return result;
}
void Luces(int minutos, int horas) {
int LucesAzules;
int InicioAmanecerAzul=900; //Amanece azules a las 15 horas
int FinAmanecerAzul=930; // Termina amanecer azules a las 15 y 30 minutos
int InicioAnochecerAzul=1411; // Empieza a anochecer azules a las 23 y 30 minutos
int FinAnochecerAzul=1440; // Se apagan los azules a las 24 horas
int MaxAzul=255;
int PorcentAzules;
int PasoAzulAM=MaxAzul/(FinAmanecerAzul-InicioAmanecerAzul);
int PasoAzulPM=MaxAzul/(FinAnochecerAzul-InicioAnochecerAzul);
int LucesMixtas;
int InicioAmanecerMixtas=931; //Empiezan Mixtas a las 15 y 30 horas
int FinAmanecerMixtas=960; // Terminan Mixtas a las 16:00
int InicioAnochecerMixtas=1380; //Empieza anochecer Mixtas a las 23:00
int FinAnochecerMixtas=1410; // Terminan anochecer Mixtas a las 23:30 horas
int MaxMixtas=255;
int PorcentMixtas;
int PasoMixtasAM=MaxMixtas/(FinAmanecerMixtas-InicioAmanecerMixtas);
int PasoMixtasPM=MaxMixtas/(FinAnochecerMixtas-InicioAnochecerMixtas);
int LucesBlancas;
int InicioAmanecerBlancas=961; // empieza amanecer blancas a las 16:00
int FinAmanecerBlancas=990; // Termina amanecer blancas a las 16:30 horas
int InicioAnochecerBlancas=1350; //Empieza atardecer blancas a las 22:30 horas
int FinAnochecerBlancas=1379;// Termina atardecer blancas a las 23:00
int MaxBlancas=255;
int PorcentBlancas;
int PasoBlancasAM=MaxBlancas/(FinAmanecerBlancas-InicioAmanecerBlancas);
int PasoBlancasPM=MaxBlancas/(FinAnochecerBlancas-InicioAnochecerBlancas);
int Tiempo;
Tiempo=horas*60+minutos;
//################################# AZULES ###################################
//Noche
if (Tiempo < InicioAmanecerAzul)LucesAzules=0;
//Amanecer
if (Tiempo >= InicioAmanecerAzul && Tiempo <= FinAmanecerAzul) LucesAzules=(Tiempo-InicioAmanecerAzul)*PasoAzulAM;
//Dia
if (Tiempo > FinAmanecerAzul && Tiempo < InicioAnochecerAzul) LucesAzules=MaxAzul;
//Anochecer
if (Tiempo >= InicioAnochecerAzul && Tiempo <= FinAnochecerAzul) LucesAzules=(FinAnochecerAzul-Tiempo)*PasoAzulPM;
//Control
if( LucesAzules <0) LucesAzules=0;
if( LucesAzules >MaxAzul) LucesAzules=MaxAzul;
//################################# MIXTAS ###################################
//Noche
if (Tiempo < InicioAmanecerMixtas) LucesMixtas=0;
//Amanecer
if (Tiempo >= InicioAmanecerMixtas && Tiempo <= FinAmanecerMixtas) LucesMixtas=(Tiempo-InicioAmanecerMixtas)*PasoMixtasAM;
//Dia
if (Tiempo > FinAmanecerMixtas && Tiempo < InicioAnochecerMixtas) LucesMixtas=MaxMixtas;
//Anochecer
if (Tiempo >= InicioAnochecerMixtas && Tiempo <= FinAnochecerMixtas) LucesMixtas=(FinAnochecerMixtas-Tiempo)*PasoMixtasPM;
//Control
if( LucesMixtas <0) LucesMixtas=0;
if( LucesMixtas >MaxMixtas) LucesMixtas=MaxMixtas;
//################################# BLANCAS ###################################
//Noche
if (Tiempo < InicioAmanecerBlancas) LucesBlancas=0;
//Amanecer
if (Tiempo >= InicioAmanecerBlancas && Tiempo <= FinAmanecerBlancas) LucesBlancas=(Tiempo-InicioAmanecerBlancas)*PasoBlancasAM;
//Dia
if (Tiempo > FinAmanecerBlancas && Tiempo < InicioAnochecerBlancas) LucesBlancas=MaxBlancas;
//Anochecer
if (Tiempo >= InicioAnochecerBlancas && Tiempo <= FinAnochecerBlancas) LucesBlancas=(FinAnochecerBlancas-Tiempo)*PasoBlancasPM;
//Control
if( LucesBlancas <0) LucesBlancas=0;
if( LucesBlancas >MaxBlancas) LucesBlancas=MaxBlancas;
analogWrite(pinFase1, LucesAzules);
analogWrite(pinFase2, LucesBlancas);
analogWrite(pinFase3, LucesMixtas);
PorcentAzules=Porcent(LucesAzules,255)*2;
PorcentBlancas=Porcent(LucesBlancas,255)*2;
PorcentMixtas=Porcent(LucesMixtas,255)*2;
/////////////////////////////////////////////////////
////////////// INOFORMACION EN PANTALLA LCD//////////
/////////////////////////////////////////////////////
lcd.clear();
lcd.setCursor(1,0);
lcd.print("CONTROL DE ACUARIO"); //////////////PRIMERA PANTALLA//////////////
lcd.setCursor(0,1);
lcd.print("====================");
lcd.setCursor(0,3);
if (dayOfMonth < 10) lcd.print("0");
lcd.print(dayOfMonth, DEC);
lcd.print("/");
if (month < 10) lcd.print("0");
lcd.print(month, DEC);
lcd.print("/");
if (year < 10) lcd.print("0");
lcd.setCursor(6,3);
lcd.print("20");
lcd.print(year, DEC);
lcd.setCursor(12,2);
lcd.print("Hora");
lcd.setCursor(12,3);
if (hour < 10) lcd.print("0");
lcd.print(hour, DEC);
lcd.print(":");
if (minute < 10) lcd.print("0");
lcd.print(minute, DEC);
lcd.print(":");
if (second < 10) lcd.print("0");
lcd.print(second, DEC);
lcd.setCursor(0,2);
switch (dayOfWeek)
{
case 1:
lcd.print("Lunes");
break;
case 2:
lcd.print("Martes");
break;
case 3:
lcd.print("Miercoles");
break;
case 4:
lcd.print("Jueves");
break;
case 5:
lcd.print("Viernes");
break;
case 6:
lcd.print("Sabado");
break;
case 7:
lcd.print("Domingo");
break;
}
delay(Retraso);
lcd.clear();
lcd.setCursor(4,0);
lcd.print("ILUMINACION");/////////////////////SEGUNDA PANTALLA - INFORMACION FASE AZULES////////////////////
lcd.setCursor(0,1);
lcd.print ("====================");
lcd.setCursor(0,3);
lcd.print("Fase Azules ");
if (PorcentAzules < 100) lcd.print(" ");
lcd.print(PorcentAzules);
lcd.print("%");
lcd.setCursor(0,2);
if (Tiempo > InicioAmanecerAzul && Tiempo < FinAmanecerMixtas) lcd.print (" AMANECIENDO ");
if (Tiempo > FinAmanecerMixtas && Tiempo < InicioAnochecerMixtas) lcd.print (" LUCE EL SOL ");
if (Tiempo >= InicioAnochecerMixtas && Tiempo <= FinAnochecerAzul) lcd.print (" ANOCHECIENDO ");
if (Tiempo > FinAnochecerAzul || Tiempo < InicioAmanecerAzul) lcd.print (" NOCHE ");
delay(Retraso);
lcd.clear();
lcd.setCursor(4,0);
lcd.print("ILUMINACION");/////////////////////TERCERA PANTALLA - INFORMACION FASE BLANCOS////////////////////
lcd.setCursor(0,1);
lcd.print ("====================");
lcd.setCursor(0,3);
lcd.print("Blanco Medio ");
if (PorcentAzules < 100) lcd.print(" ");
lcd.print(PorcentBlancas);
lcd.print("%");
lcd.setCursor(0,2);
if (Tiempo > InicioAmanecerAzul && Tiempo < FinAmanecerMixtas) lcd.print (" AMANECIENDO ");
if (Tiempo > FinAmanecerMixtas && Tiempo < InicioAnochecerMixtas) lcd.print (" LUCE EL SOL ");
if (Tiempo >= InicioAnochecerMixtas && Tiempo <= FinAnochecerAzul) lcd.print (" ANOCHECIENDO ");
if (Tiempo > FinAnochecerAzul || Tiempo < InicioAmanecerAzul) lcd.print (" NOCHE ");
delay(Retraso);
lcd.clear();
lcd.setCursor(4,0);
lcd.print("ILUMINACION");/////////////////////CUARTA PANTALLA - INFORMACION FASE BLANCO TOTAL////////////////////
lcd.setCursor(0,1);
lcd.print ("====================");
lcd.setCursor(0,3);
lcd.print("Blanco Total ");
if (PorcentAzules < 100) lcd.print(" ");
lcd.print(PorcentMixtas);
lcd.print("%");
lcd.setCursor(0,2);
if (Tiempo > InicioAmanecerAzul && Tiempo < FinAmanecerMixtas) lcd.print (" AMANECIENDO ");
if (Tiempo > FinAmanecerMixtas && Tiempo < InicioAnochecerMixtas) lcd.print (" LUCE EL SOL ");
if (Tiempo >= InicioAnochecerMixtas && Tiempo <= FinAnochecerAzul) lcd.print (" ANOCHECIENDO ");
if (Tiempo > FinAnochecerAzul || Tiempo < InicioAmanecerAzul) lcd.print (" NOCHE ");
delay(Retraso);
lcd.clear();
lcd.setCursor(4,0);
lcd.print("TEMPERATURA");///////////////////////CUARTA PANTALLA - TEMPERATURA//////////////////////////
lcd.setCursor(0,1);
lcd.print("====================");
lcd.setCursor(0,2);
lcd.print("AGUA ");
sensors.requestTemperatures();
lcd.print(sensors.getTempCByIndex(1),1);
lcd.setCursor(17,2);
if (sensors.getTempCByIndex(1)>=27.00){ //////////ENCENDEMOS VENTILADOR PANTALLA/////////////////
lcd.print("ON");
digitalWrite(pinRele1, LOW);}
else if (sensors.getTempCByIndex(1)<25.00){
lcd.print("OFF");
digitalWrite(pinRele1, HIGH);}
lcd.setCursor(13,2);
lcd.print("\337C");
lcd.setCursor(0,3);
lcd.print("AMBIENTE ");
sensors.requestTemperatures();
lcd.print(sensors.getTempCByIndex(0),1);
lcd.setCursor(16,3);
lcd.print("\337C");
delay(Retraso3);
}
////////////////////////////////////////////////////////////////////////
///////////////////////// FUNCIONES AUXILIARES /////////////////////////
////////////////////////////////////////////////////////////////////////
// Establece la fecha y el tiempo del ds1307
void getDateDs1307(byte *second,
byte *minute,
byte *hour,
byte *dayOfWeek,
byte *dayOfMonth,
byte *month,
byte *year)
{
// Resetea el registro puntero
Wire.beginTransmission(DS1307_I2C_ADDRESS);
Wire.send(0);
Wire.endTransmission();
Wire.requestFrom(DS1307_I2C_ADDRESS, 7);
// Alguno de estos necesitan enmascarar porque ciertos bits son bits de control
*second = bcdToDec(Wire.receive() & 0x7f);
*minute = bcdToDec(Wire.receive());
*hour = bcdToDec(Wire.receive() & 0x3f); // Need to change this if 12 hour am/pm
*dayOfWeek = bcdToDec(Wire.receive());
*dayOfMonth = bcdToDec(Wire.receive());
*month = bcdToDec(Wire.receive());
*year = bcdToDec(Wire.receive());
}
![[TodoMarino.com] coscorrones contra la pared [TodoMarino.com] coscorrones contra la pared](https://i130.photobucket.com/albums/p264/pomacantus73/2DS18x20_zps534e4f50.png)