Hola estoy haciendo un proyecto y me da error al compilarlo en las funciones.
Pego el codigo y los errores de compilacion a ver si alguien puede ayudarme.
Gracias de antemano
// variable del numero de humedad que tiene que haber para que haya riego
const int humedad = 30;
// variables para los pines de las bombas
const int B2 = 6;
const int B3 = 7;
const int B4 = 8;
const int B5 = 9;
const int B6 = 10;
// variable pin sensor de luz
const int S0 = 11;
// Variables pines sensores de humedad
const int S1 = A1;
const int S2 = A2;
const int S3 = A3;
const int S4 = A4;
const int S5 = A5;
// defino la variable noche para saber si es de dia o de noche
int noche = 0;
// defino variables para saber si se puede regar o no
int R1 = 0;
int R2 = 0;
int R3 = 0;
int R4 = 0;
int R5 = 0;
// defino variable dly para saber cada cuanto tiempo tarda en leer los sensores, si es 0 cada 30 min. si es 1 cada 1 segundo.
int dly = 0;
void setup()
{
// abrimos el puerto serial a 9600 bps
Serial.begin(9600);
// pines digitales arduino declarados como salidas y el del sensor de luz como entrada
pinMode(B2, OUTPUT);
pinMode(B3, OUTPUT);
pinMode(B4, OUTPUT);
pinMode(B5, OUTPUT);
pinMode(B6, OUTPUT);
pinMode(S0, INPUT);
//definimos pines analogicos como entradas
pinMode(S1, INPUT);
pinMode(S2, INPUT);
pinMode(S3, INPUT);
pinMode(S4, INPUT);
pinMode(S5, INPUT);
// declara los pines con 0 Voltios
digitalWrite(B2, LOW);
digitalWrite(B3, LOW);
digitalWrite(B4, LOW);
digitalWrite(B5, LOW);
digitalWrite(B6, LOW);
digitalWrite(S0, LOW);
}
void loop()
{
// empiezo la programacion
fluz();
fdianoche();
if (dly == 0)
{
delay(180000);
}
if (dly == 1)
{
fhumedad();
fregando();
}
if (B2 == HIGH || B3 == HIGH || B4 == HIGH || B5 == HIGH || B6 == HIGH)
{
delay(1000);
}
// Defino Funciones
int fluz()
{
int luz = digitalRead(S0);
return = luz;
int H1 = analogRead(S1);
return = H1;
int H2 = analogRead(S2);
return = H2;
int H3 = analogRead(S3);
return = H3;
int H4 = analogRead(S4);
return = H4;
int H5 = analogRead(S5);
return = H5;
break;
}
int fdianoche()
{
if (int luz == LOW)
{
int noche = 0;// si el valor es superior a 30 se supone que es de dia y noche se pone en 0 para que no riege
int dly = 0;
return = noche;
return = dly;
}
if (int luz == HIGH)
{
int noche = 1;// pongo la variable noche en 1 para que pueda regar
int dly = 1;
return = noche;
return = dly;
break;
}
}
int fhumedad()
{
if (H1 < humedad) // 30 hay que probar cuando la tierra esta seca o mojada
{
int R1 = 1;// 1 si la tierra esta seca y se debe regar
return = R1;
}
else {
int R1 = 0;// 0 si la tierra esta humeda y no se debe regar
return = R1;
}
if (H2 < humedad) // 30 hay que probar cuando la tierra esta seca o mojada
{
int R2 = 1;
return = R2;
}
else {
int R2 = 0;
return = R2;
}
if (H3 < humedad)
{
int R3 = 1;
return = R3;
}
else {
int R3 = 0;
return = R3;
}
if (H4 < humedad)
{
int R4 = 1;
return = R4;
}
else {
int R4 = 0;
return = R4;
}
if (H5 < humedad)
{
int R5 = 1;
return = R5;
}
else {
int R5 = 0;
return = R5;
break;
}
}
int fregando()
{
if (noche == 1 && H1 == 1)
{
digitalWrite(B2, HIGH);
}
if (noche == 1 && H2 == 1)
{
digitalWrite(B3, HIGH);
}
if (noche == 1 && H3 == 1)
{
digitalWrite(B4, HIGH);
}
if (noche == 1 && H4 == 1)
{
digitalWrite(B5, HIGH);
}
if (noche == 1 && H5 == 1)
{
digitalWrite(B6, HIGH);
break;
}
}
Los errores son estos
F7DYTEZIIOUK8WQ:70: error: 'fluz' was not declared in this scope
fluz();
^
F7DYTEZIIOUK8WQ:71: error: 'fdianoche' was not declared in this scope
fdianoche();
^
F7DYTEZIIOUK8WQ:79: error: 'fhumedad' was not declared in this scope
fhumedad();
^
F7DYTEZIIOUK8WQ:80: error: 'fregando' was not declared in this scope
fregando();
^
F7DYTEZIIOUK8WQ:90: error: a function-definition is not allowed here before '{' token
{
^
F7DYTEZIIOUK8WQ:107: error: a function-definition is not allowed here before '{' token
{
^
F7DYTEZIIOUK8WQ:207: error: expected '}' at end of input
}
^
exit status 1
'fluz' was not declared in this scope
Moderador: Agregado de etiquetas a los errores.