This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

  • 0 voto(s) - 0 Media
  • 1
  • 2
  • 3
  • 4
  • 5
CONSULTA error al compilar exit status1 error al compilar tarjeta arduino uno
#1
no he podido compilarlo , desde ya muchas gracias por su tiempo

#include <LiquidCrystal.h>  // includes the LiquidCrystal Library
#include <math.h>    //para el redondeo
   
LiquidCrystal lcd(2, 3, 4, 5, 6, 7);  // Creates an LCD object. Parameters: (rs, enable, d4, d5, d6, d7)
// Connect panel using the standard lines.

// Sensor 1, trigger pin 13 y echo pin 12.
const int trigPin1 = 13;
const int echoPin1 = 12;

// Sensor 2, trigger pin 11 y echo pin 10.
const int trigPin2 = 11;
const int echoPin2 = 10;

// dimensiones Tanque 1 (el que esta en la parte inferior) en metros.
const float lengthBottomTankM = 3.2;
const float widthBottomTankM = 2;
const float deepBottomTankM = 1.7;
const float volTotalBottomTankM3 = 8.96;    // Restado 0.3 de distancia al sensor tanque inferior

// dimensiones Tanque 2 (el que esta en la parte inferior) en mestros
const float lengthUpTankM = 2.74;
const float widthUpTankM = 2;
const float deepUpTankM = 1.9;
const float volTotalUpTankM3 = 9.32;    // Restado 0.2 de distancia al sensor tanque superior
 
long duration1;
float deepBottomTankCm;

long duration2;
float deepUpTankCm;

float volumeBottomTank;
float volumeUpTank;

float porcBottomTank;
float porcUpTank;

void setup() {
  lcd.begin(16,2);  // Initializes the interface to the LCD screen, and specifies the dimensions (width and height) of the display
  pinMode(trigPin1, OUTPUT);
  pinMode(echoPin1, INPUT);
  pinMode(trigPin2, OUTPUT);
  pinMode(echoPin2, INPUT);
  Serial.begin (9600);   
}
 
void loop() {
// Trigger Lower tank
  digitalWrite(trigPin1, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin1, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin1, LOW);
  duration1 = pulseIn(echoPin1, HIGH);
  deepBottomTankCm= duration1*0.034/2;

// Trigger upper tank
  digitalWrite(trigPin2, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin2, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin2, LOW);
  duration2 = pulseIn(echoPin2, HIGH);
  deepUpTankCm= duration2*0.034/2;

if (deepBottomTankCm > 0 && deepUpTankCm > 0) {
// Make calculations based on volume1 and volume2
  volumeBottomTank = lengthBottomTankM * widthBottomTankM * (deepBottomTankM - (float)deepBottomTankCm/100);
     
  porcBottomTank = (float)volumeBottomTank/(float)volTotalBottomTankM3 * 100; 
 
  volumeBottomTank = round(volumeBottomTank*10);
  volumeBottomTank = volumeBottomTank/10;

  volumeUpTank = lengthUpTankM * widthUpTankM * (deepUpTankM - (float)deepUpTankCm/100);
  volumeUpTank = round(volumeUpTank*10);
  volumeUpTank = volumeUpTank/10;
  porcUpTank = (float)volumeUpTank / volTotalUpTankM3 * 100;

  Serial.println("cmBottom," + String(deepBottomTankCm) + ";
  cmUp," + String(deepUpTankCm));



// Show information on LCD
  lcd.setCursor(0,0);  // Sets the location at which subsequent text written to the LCD will be displayed
  lcd.println("S: " + String(volumeUpTank) + "m3, "+ String(round(porcUpTank)) + "%      ");  // Prints string "Distance" on the LCD
  lcd.println("DistaCm: " + String(deepUpTankCm) + "      ");
     
  delay(10);

  lcd.setCursor(0,1);
  lcd.println("I: " + String(volumeBottomTank) + "m3, "+ String(round(porcBottomTank)) + "%      ");
  lcd.println("DistCm: " + String(deepBottomTankCm) + "          ");
 
}
  delay(500);
}
  Responder
#2
Si además del código incluyes el error que te tira el IDE será más probable que alguien se lo mire.
Saludos
  Responder
#3
Buenos días

El problema lo tienes en tus líneas 81 y 82

Código:
Serial.println("cmBottom," + String(deepBottomTankCm) + ";

  cmUp," + String(deepUpTankCm));


Esas líneas las has copiado mal, y la primera línea le has puesto los dos puntos para cerrarla, pero la orden esta a medias, la orden correcta es

Código:
    Serial.println("cmBottom," + String(deepBottomTankCm) + "cmUp," + String(deepUpTankCm));

Y así si compila

Un saludo.
  Responder
#4
Tu código parece estar bastante bien estructurado, pero hay algunos puntos a revisar y corregir para asegurar que compile y funcione correctamente. Aquí te dejo algunas sugerencias y correcciones:
  1. Errores en el Código:
    • Cadena de texto sin cerrar: Hay una cadena de texto en
      Serial.println
      que no está cerrada correctamente.
    • Fórmula de redondeo: La fórmula para redondear el volumen está bien, pero podrías simplificarla utilizando
      round()
      directamente.
  2. Corregir el Error de Compilación:
    • Errores de Sintaxis en
      Serial.println
      : La cadena que estás imprimiendo en el monitor serie tiene un error de sintaxis.
    • Fórmulas para el Volumen: Asegúrate de que la fórmula para el volumen y los porcentajes esté correcta.
Aquí tienes el código corregido:

#include <LiquidCrystal.h>  // includes the LiquidCrystal Library
#include <math.h>    //para el redondeo

LiquidCrystal lcd(2, 3, 4, 5, 6, 7);  // Creates an LCD object. Parameters: (rs, enable, d4, d5, d6, d7)
// Connect panel using the standard lines.

// Sensor 1, trigger pin 13 y echo pin 12.
const int trigPin1 = 13;
const int echoPin1 = 12;

// Sensor 2, trigger pin 11 y echo pin 10.
const int trigPin2 = 11;
const int echoPin2 = 10;

// dimensiones Tanque 1 (el que esta en la parte inferior) en metros.
const float lengthBottomTankM = 3.2;
const float widthBottomTankM = 2;
const float deepBottomTankM = 1.7;
const float volTotalBottomTankM3 = 8.96;    // Restado 0.3 de distancia al sensor tanque inferior

// dimensiones Tanque 2 (el que esta en la parte superior) en metros
const float lengthUpTankM = 2.74;
const float widthUpTankM = 2;
const float deepUpTankM = 1.9;
const float volTotalUpTankM3 = 9.32;    // Restado 0.2 de distancia al sensor tanque superior

long duration1;
float deepBottomTankCm;

long duration2;
float deepUpTankCm;

float volumeBottomTank;
float volumeUpTank;

float porcBottomTank;
float porcUpTank;

void setup() {
  lcd.begin(16,2);  // Initializes the interface to the LCD screen, and specifies the dimensions (width and height) of the display
  pinMode(trigPin1, OUTPUT);
  pinMode(echoPin1, INPUT);
  pinMode(trigPin2, OUTPUT);
  pinMode(echoPin2, INPUT);
  Serial.begin (9600); 
}

void loop() {
  // Trigger Lower tank
  digitalWrite(trigPin1, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin1, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin1, LOW);
  duration1 = pulseIn(echoPin1, HIGH);
  deepBottomTankCm = duration1 * 0.034 / 2;

  // Trigger Upper tank
  digitalWrite(trigPin2, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin2, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin2, LOW);
  duration2 = pulseIn(echoPin2, HIGH);
  deepUpTankCm = duration2 * 0.034 / 2;

  if (deepBottomTankCm > 0 && deepUpTankCm > 0) {
    // Make calculations based on volume1 and volume2
    volumeBottomTank = lengthBottomTankM * widthBottomTankM * (deepBottomTankM - deepBottomTankCm / 100);
    porcBottomTank = (volumeBottomTank / volTotalBottomTankM3) * 100;
    volumeBottomTank = round(volumeBottomTank * 10) / 10;

    volumeUpTank = lengthUpTankM * widthUpTankM * (deepUpTankM - deepUpTankCm / 100);
    volumeUpTank = round(volumeUpTank * 10) / 10;
    porcUpTank = (volumeUpTank / volTotalUpTankM3) * 100;

    Serial.println("cmBottom: " + String(deepBottomTankCm) + " cm, cmUp: " + String(deepUpTankCm) + " cm");

    // Show information on LCD
    lcd.setCursor(0,0);
    lcd.print("S: " + String(volumeUpTank) + "m3, " + String(round(porcUpTank)) + "%");
    lcd.setCursor(0,1);
    lcd.print("D: " + String(volumeBottomTank) + "m3, " + String(round(porcBottomTank)) + "%");
  }
 
  delay(500);  // Reduced delay for smoother updates
}



Notas Importantes:
  • Serial.println
    : Asegúrate de cerrar correctamente las cadenas de texto.
  • Escala del Volumen: Asegúrate de que las fórmulas para el cálculo del volumen y el porcentaje sean correctas según la geometría del tanque.
  • Retraso: Puedes ajustar el
    delay()
    según la necesidad de actualización en tu pantalla LCD.

Prueba el código corregido y verifica si compila y funciona como esperas. ¡Buena suerte con tu proyecto!
  Responder


Posibles temas similares…
Tema Autor Respuestas Vistas Último mensaje
  tarjeta creality silenciosa pipeferr 2 237 27-12-2024, 10:11 PM
Último mensaje: pipeferr
  DUDA Envío de datos. Tarjeta feather 32u4 Okene 4 508 29-07-2024, 10:17 PM
Último mensaje: Hectormonero
  Fusionar dos sketch en uno (código arduino) jgarridc 22 11,798 31-12-2018, 07:37 PM
Último mensaje: Surbyte
Pregunta [SOL] Tengo dos URL's en el mismo servidor en wordpress como redirigir de uno a otro Electromecánico 5 2,367 02-03-2018, 12:04 PM
Último mensaje: Electromecánico
  Problemas tarjeta de red Electromecánico 4 1,877 17-04-2015, 12:33 PM
Último mensaje: jumasape