Go Down

Topic: headache from trying to find the error, HELP PLEASE! (Read 1 time) previous topic - next topic

cgermanb

Hi people, I have a headache from trying to find the error, could you please help me?


y have this error:


test.ino: In function 'void loop()':
test.ino:136:3: error: a function-definition is not allowed here before '{' token
test.ino:148:3: error: a function-definition is not allowed here before '{' token
test.ino:152:3: error: expected '}' at end of input
Error de compilaciĆ³n

the code:



Code: [Select]

#include <DallasTemperature.h>
#include <OneWire.h>
#include "RelojDS1307.h"
#include "RTClib.h"
#include <Wire.h>
#include <LiquidCrystal.h>




#define TEMP           7
#define LUZ            8
#define LUZLUNA        4
#define CAL1           5
#define VENT           6


LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
OneWire oneWire(TEMP);
DallasTemperature sensors(&oneWire);
DeviceAddress ACUARIO;
RelojDS1307Class Reloj;

void setup()
{
  Serial.begin(9600);
  lcd.begin(16, 2);

  pinMode(LUZ, OUTPUT);
  pinMode(LUZLUNA, OUTPUT);
  pinMode(CAL1, OUTPUT);
  pinMode(VENT, OUTPUT);

  Serial.print("Localizando sondas de temperatura: ");
  Serial.print("Encontradas  ");
  Serial.print(sensors.getDeviceCount(), DEC);
  Serial.println(" sondas.");
  lcd.setCursor(4, 0);
  lcd.print("ARDUINO WATER");
  lcd.setCursor(5, 2);
  lcd.print("CICLIDOS");
  delay(5000);
  //Reloj.SetDateTime( 17, 04, 13, 20, 47, 00 );
}

void loop()
{
  Serial.print("Recibiendo temperaturas...");
  sensors.requestTemperatures();
  Serial.println("OK");

  printData(ACUARIO);


  float AGUA1 = sensors.getTempC(ACUARIO);

  if (AGUA1 < 25)
  {
    digitalWrite (CAL1, HIGH);
    lcd.setCursor(19, 1);
    lcd.print("I");
  }

  if (AGUA1 > 27)
  {
    digitalWrite (CAL1, LOW);
    digitalWrite (VENT, HIGH);
    lcd.setCursor(19, 2);
    lcd.print("O");
  }

  if (AGUA1 > 29)
  {
    digitalWrite (VENT, HIGH);
    digitalWrite (LUZ, LOW);
    digitalWrite (LUZLUNA, LOW);
    lcd.setCursor(19, 3);
    lcd.print("V");
  }
  
  if (Reloj.IsLater(7, 05) && Reloj.IsPrevious(8, 05))
  {
    digitalWrite(LUZ, HIGH);
    digitalWrite(LUZLUNA, HIGH);
  }
  else
  {
    digitalWrite(LUZ, LOW);
    digitalWrite(LUZLUNA, LOW);
  }

  if (Reloj.IsLater(14, 05) && Reloj.IsPrevious(15, 05))
  {
    digitalWrite(LUZ, HIGH);
    digitalWrite(LUZLUNA, HIGH);
  }
  else
  {
    digitalWrite(LUZ, LOW);
    digitalWrite(LUZLUNA, LOW);
  }
  if (Reloj.IsLater(17, 05) && Reloj.IsPrevious(23, 05))
  {
    digitalWrite(LUZ, HIGH);
    digitalWrite(LUZLUNA, HIGH);
  }
  else
  {
    digitalWrite(LUZ, LOW);
    digitalWrite(LUZLUNA, LOW);
  }
  if (Reloj.IsLater(23, 05) && Reloj.IsPrevious(23, 25))
  {
    digitalWrite(LUZ, LOW);
    digitalWrite(LUZLUNA, HIGH);
  }
  else
  {
    digitalWrite(LUZ, LOW);
    digitalWrite(LUZLUNA, LOW);
  }

  if (!sensors.getAddress(ACUARIO, 0))
  {
    Serial.println("INCAPAZ DE ENCONTRAR SONDA ACUARIO");
    lcd.setCursor(0, 1);
    lcd.print("FALLO S1");
  }
  if (sensors.getAddress(ACUARIO, 0))
  {
    lcd.setCursor(0, 1);
    lcd.print("S1 -- OK");
  }

  void printTemperature(DeviceAddress)
  {
    float AGUA1 = sensors.getTempC(ACUARIO);
    Serial.print("ACUARIO: ");
    Serial.print(AGUA1);
    Serial.print("  ");
    lcd.setCursor(0, 0);
    lcd.print(Reloj.DateTime());
    lcd.setCursor(0, 2);
    lcd.print("ACUARIO:  ");
    lcd.print(AGUA1);
  }
  void printData(DeviceAddress)
  {
    Serial.print(" "); //ver
    printTemperature(deviceAddress);
    Serial.println();
  }


KeithRB


Xen0n

You forgot to close the loop in line 135 with a }

econjack

#3
Feb 11, 2015, 09:31 pm Last Edit: Feb 11, 2015, 09:31 pm by econjack
You define an object named

DeviceAddress ACUARIO;

but when you define your functions, you never supply the variable in the signature. For example, you define:

Code: [Select]

  void printData(DeviceAddress)
  {
    Serial.print(" "); //ver
    printTemperature(deviceAddress);
    Serial.println();
  }



but you never supply the function parameter. All you are supplying is the type specifier. You need to modify it to be:


Code: [Select]

  void printData(DeviceAddress myDevice)
  {
    Serial.print(" "); //ver
    printTemperature(myDevice);
    Serial.println();
  }





cgermanb

You define an object named

DeviceAddress ACUARIO;

but when you define your functions, you never supply the variable in the signature. For example, you define:

Code: [Select]

  void printData(DeviceAddress)
  {
    Serial.print(" "); //ver
    printTemperature(deviceAddress);
    Serial.println();
  }



but you never supply the function parameter. All you are supplying is the type specifier. You need to modify it to be:


Code: [Select]

  void printData(DeviceAddress myDevice)
  {
    Serial.print(" "); //ver
    printTemperature(myDevice);
    Serial.println();
  }





i do this

Code: [Select]

  void printData(DeviceAddress ACUARIO)
  {
    Serial.print(" ");
    printTemperature(ACUARIO);
    Serial.println();
  }



is right?

now i have this error:

C:\Program Files (x86)\Arduino\libraries\DallasTemperature\DallasTemperature.cpp:9:26: fatal error: WConstants.h: No such file or directory
   #include "WConstants.h"
                          ^
compilation terminated.
Error de compilaciĆ³n

michinyon

Try adding  #include "Arduino.h"  at the start of your program.


Robin2

@jakehodges1985, you have resurrected a 5-years-dead Thread.

If you have a problem with a program then please start a new Thread and include your program and a description of the problem.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

Go Up