Exit status 1 redefinition of 'void setup()'

Good Afternoon everyone, i'm working on a little project and i'm trying to make two codes run at the same time, i want the first one to read and display the data of that the sensor of the second code detects in a lcd display but i'm running into this error : exit status 1 redefinition of 'void setup()'

code:
'''

const int PINO_SENSOR = A0;

const int PINO_RELE = 2;

int leitura_sensor = 0;

bool pausa = true;

const int VALOR_MAXIMO = 900; //Valor com solo seco
const int VALOR_MINIMO = 700; //Valor com solo umido

const int CONCENTRACAO_MINIMA = 30;
const int CONCENTRACAO_MAXIMA = 50;

void setup()
{

pinMode(PINO_SENSOR, INPUT);

pinMode(PINO_RELE, OUTPUT);

digitalWrite(PINO_RELE, LOW);

}

void loop() {

leitura_sensor = analogRead(PINO_SENSOR);
leitura_sensor = map(leitura_sensor, VALOR_MINIMO, VALOR_MAXIMO, 100, 0);

if(leitura_sensor < CONCENTRACAO_MINIMA){ //Se sim
digitalWrite(PINO_RELE, HIGH); //Acionamos o rele
pausa = false;
} else if (leitura_sensor > CONCENTRACAO_MAXIMA) { //Caso contrario
digitalWrite(PINO_RELE, LOW);
pausa = true;
}

if(pausa){ //Se sim
delay(10000); //A linha acima aguarda 10 segundos para uma nova leitura
}

}

// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(7,8,9,10,11,12);

int potPin1 = A1;
int potPin2 = A2;

// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
lcd.clear();

pinMode(potPin1, INPUT);
pinMode(potPin2, INPUT);

lcd.setCursor(0,0); // Sets the cursor to col 0 and row 0
lcd.print("SensorVal1: "); // Prints Sensor Val: to LCD
lcd.print(analogRead(potPin1)); // Prints value on Potpin1 to LCD
lcd.setCursor(0,1); // Sets the cursor to col 1 and row 0
lcd.print("SensorVal2: "); // Prints Sensor Val: to LCD
lcd.print(analogRead(potPin2)); // Prints value on Potpin1 to LCD

'''

Hello
The sketch contains multiple functions calls for loop() and setup().

You can only have one setup() and one loop() function.

You need to merge the two pieces of code into a single setup() and a single loop() function. It is not enough to simply copy two programs together.

Thank you!

Thanks!

Thanks PaulPaulson and @ToddL1962

Hey guys @paulpaulson @ToddL1962 (and Kai-R) thanks for the help! i think i've managed to fix it doing what you guys said (i only used one loop and setup) but now i'm running into the following errors:

sketch_sep26a:61:1: error: 'lcd' does not name a type

lcd.begin(16, 2);

^~~

sketch_sep26a:62:1: error: 'lcd' does not name a type

lcd.clear();

^~~

sketch_sep26a:64:8: error: expected constructor, destructor, or type conversion before '(' token

pinMode(potPin1, INPUT);

    ^

sketch_sep26a:65:8: error: expected constructor, destructor, or type conversion before '(' token

pinMode(potPin2, INPUT);

    ^

sketch_sep26a:69:1: error: 'lcd' does not name a type

lcd.setCursor(0,0); // Sets the cursor to col 0 and row 0

^~~

sketch_sep26a:70:1: error: 'lcd' does not name a type

lcd.print("SensorVal1: "); // Prints Sensor Val: to LCD

^~~

sketch_sep26a:71:1: error: 'lcd' does not name a type

lcd.print(analogRead(potPin1)); // Prints value on Potpin1 to LCD

^~~

sketch_sep26a:72:1: error: 'lcd' does not name a type

lcd.setCursor(0,1); // Sets the cursor to col 1 and row 0

^~~

sketch_sep26a:73:1: error: 'lcd' does not name a type

lcd.print("SensorVal2: "); // Prints Sensor Val: to LCD

^~~

sketch_sep26a:74:1: error: 'lcd' does not name a type

lcd.print(analogRead(potPin2)); // Prints value on Potpin1 to LCD

^~~

exit status 1

'lcd' does not name a type

i appreciate any help, sorry for my mistakes i'm a beginner!

Post your updated code.
First, click the code tag button in the reply editor, it looks like this </>.
Then, paste your code where it says to.

posted!

Don't modify sketches in the existing posts. Post updated sketches in a new reply.

I think that you tried to use code tags but it did not quite work out. Instead of using ''', use ``` (called backticks)

You should take a look at the sample programs that are included with the IDE to memorize the structure of an Arduino C/C++ program.

I have adapted your code so that it can at least be compiled. But it is doubtful that the program works as you imagine it.

// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

int potPin1 = A1;
int potPin2 = A2;

const int PINO_SENSOR = A0;
const int PINO_RELE = 2;

int leitura_sensor = 0;
bool pausa = true;

const int VALOR_MAXIMO = 900; //Valor com solo seco
const int VALOR_MINIMO = 700; //Valor com solo umido
const int CONCENTRACAO_MINIMA = 30;
const int CONCENTRACAO_MAXIMA = 50;

void setup() {
  pinMode(PINO_RELE, OUTPUT);
  pinMode(PINO_SENSOR, INPUT);
  pinMode(potPin1, INPUT);
  pinMode(potPin2, INPUT);

  digitalWrite(PINO_RELE, LOW);
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  lcd.clear();
}

void loop() {

  leitura_sensor = analogRead(PINO_SENSOR);
  leitura_sensor = map(leitura_sensor, VALOR_MINIMO, VALOR_MAXIMO, 100, 0);

  if (leitura_sensor < CONCENTRACAO_MINIMA) { //Se sim
    digitalWrite(PINO_RELE, HIGH); //Acionamos o rele
    pausa = false;
  } else if (leitura_sensor > CONCENTRACAO_MAXIMA) { //Caso contrario
    digitalWrite(PINO_RELE, LOW);
    pausa = true;
  }

  lcd.setCursor(0, 0); // Sets the cursor to col 0 and row 0
  lcd.print("SensorVal1: "); // Prints Sensor Val: to LCD
  lcd.print(analogRead(potPin1)); // Prints value on Potpin1 to LCD
  lcd.setCursor(0, 1); // Sets the cursor to col 1 and row 0
  lcd.print("SensorVal2: "); // Prints Sensor Val: to LCD
  lcd.print(analogRead(potPin2)); // Prints value on Potpin1 to LCD

  if (pausa) { //Se sim
    delay(10000); //A linha acima aguarda 10 segundos para uma nova leitura
  }
}

Thanks man, i really appreciate it, it's for a school project, i'm a begginer in programming and in this forum but i'm trying my best! :slight_smile:

Ok, thanks!