Hola!
Estoy teniendo este problema con el siguiente codigo, es un problema que he tenido antes al no declarar una variable antes de querer usarla, pero en este caso la variable "clima" si esta declarada, que más podría ser?
Soy novato xD agradezco mucho su ayuda!
PD: puse en negritas donde me marca los errores.
#include <Wire.h> //Incluimos Libreria I2C //Siempre que utilicemos I2C se necesitara esta libreria + la del dispositivo.
#include <RTClib.h> //Libreria del RTC DS1307
RTC_DS1307 rtc; //Genera instancia "rtc" de la clase RTC_DS1307
int ledNort = 3;
int ledSouth = 4;
int ledEast = 5;
int ledWest = 6;
int btClima = 12;
//Variables de tiempo
int dia;
int clima = 1;
unsigned int hora;
unsigned int minu;
unsigned int sec;
// Bloque de inicializacion de parametros
void setup ()
{
Serial.begin(9600);
Wire.begin(); //Inicializa la clase I2C
rtc.begin(); //Inicializa el objeto "rtc"
pinMode(ledNort, OUTPUT);
pinMode(ledSouth, OUTPUT);
pinMode(ledWest, OUTPUT);
pinMode(ledEast, OUTPUT);
pinMode(btClima, INPUT_PULLUP);
delay(100);
//rtc.adjust(DateTime(__DATE__, __TIME__)); //Para programar el dispositivo (Toma fecha y hora de la ultima compilación)
rtc.adjust(DateTime(21, 10, 11, 4, 59, 55)); //Año, mes, dia, hora, minuto, segundo //Con este vamos a asignar la hora donde iniciaremos el regado
if (! rtc.isrunning()) {
Serial.println("El RTC NO esta operando!");
// rtc.adjust(DateTime(__DATE__, __TIME__)); //Esta linea establece la fecha y hora
} // del archivo de compilacion de este sketch
}
void loop ()
{
DateTime now = rtc.now(); //Genera variable "now" del tipo estructura DateTime
//y lo iguala a la variable now del RTC
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.print(now.dayOfWeek(), DEC);
Serial.println();
delay(1000);
dia = now.dayOfWeek();
hora = now.hour();
minu = now.minute();
sec = now.second();
//Control del clima
**if(digitalRead(btClima) = LOW and clima == 1)**
{
clima = 2;
rtc.adjust(DateTime(21, 10, 10, 17, 59, 55));
}
**if(digitalRead(btClima) = LOW and clima == 2)**
{
clima = 1;
rtc.adjust(DateTime(21, 10, 11, 4, 59, 55));
}
//Control del riego VERANO - Escala 1:3
if(clima == 1)
{
if (dia == 1 or dia == 3 or dia == 6)
{
if (hora == 5 and minu == 0 and sec == 0)
{
digitalWrite(ledNort, HIGH);
}
else if (hora == 5 and minu == 0 and sec == 5)
{
digitalWrite(ledNort, LOW);
digitalWrite(ledSouth, HIGH);
}
else if (hora == 5 and minu == 0 and sec == 15)
{
digitalWrite(ledSouth, LOW);
digitalWrite(ledEast, HIGH);
}
else if (hora == 5 and minu == 1 and sec == 20)
{
digitalWrite(ledEast, LOW);
digitalWrite(ledWest, HIGH);
}
else if (hora == 5 and minu == 1 and sec == 30)
{
digitalWrite(ledWest, LOW);
}
}
}
//Control del riego INVIERNO - Escala 1:5
if(clima == 2)
{
if (dia == 7)
{
if (hora == 18 and minu == 0 and sec == 0)
{
digitalWrite(ledNort, HIGH);
}
else if (hora == 18 and minu == 0 and sec == 6)
{
digitalWrite(ledNort, LOW);
digitalWrite(ledSouth, HIGH);
}
else if (hora == 5 and minu == 0 and sec == 18)
{
digitalWrite(ledSouth, LOW);
digitalWrite(ledEast, HIGH);
}
else if (hora == 5 and minu == 0 and sec == 24)
{
digitalWrite(ledEast, LOW);
digitalWrite(ledWest, HIGH);
}
else if (hora == 5 and minu == 0 and sec == 36)
{
digitalWrite(ledWest, LOW);
}
}
}
}