Question: how to join two different codes I’m dabbling in Arduino and having trouble running two sketches on my Arduino UNO simultaneously. The first is about a program that reads temperature and relative humidity and the second is a program that reads barometric pressure. Both programs work independently, but when I try to combine the two, No
help
this is the code for temperature and relative humidity:


#include &lt;Adafruit_Sensor.h&gt;
#include &lt;LiquidCrystal.h&gt;
#include &lt;DHT.h&gt;
#include &lt;DHT_U.h&gt;

//VARIABLES
//Asignación de los pines digitales
int SENSOR = 2; //Este es el pin #2
int RS = 4;
int E = 5;
int D4 = 6;
int D5 = 7;
int D6 = 8;
int D7 = 9;
//Variables de lectura de tempratura y humedad
int temp;
int hume;
//Creación de variables para el sensor y el display
DHT dht(SENSOR,DHT11);                    //Formato general: DHT &lt;var_name&gt;(PIN, MODELO DEL SENSOR)
LiquidCrystal lcd(RS, E, D4, D5, D6, D7); // Formato general: LiquidCrystal &lt;var_name&gt;(RS, RW, ENABLE, D0, D1, D2, D3, D4, D5, D6, D7)
//Variable para salida del abanico
int motor = 12;

void setup(){
  
  //Iniciar el sensor de temp
  dht.begin();
  //Iniciar el LCD
  lcd.begin(16,2); //(tipo 16 columnas, 2 líneas)
  //Setea el Pin 12 como salida
  pinMode(motor,OUTPUT);
         
}

void loop(){ //Este es el buclé principal del programa

  //Lee valores físicos
  hume = dht.readHumidity();
  temp = dht.readTemperature();

  //Limpia el LCD
  lcd.clear(); //esta instrucción coloca el cursor en la pos 0,0 (columna, fila)
  lcd.setCursor(0,0); //(no necesaria porque la linea de arriba ya lo hace)
  //Escribe los valores leídos en el LCD
  lcd.print(&quot;TEMPERATURA: &quot;);
  lcd.print(temp);
  lcd.print(&quot;C&quot;);
  lcd.setCursor(0,1); //esta instrucción coloca el cursor en la pos 0,1 (columna, fila)
  lcd.print(&quot;HUMEDAD: &quot;);
  lcd.print(hume);
  lcd.print(&quot;%&quot;);

  //Activa el motor si la temperatura pasa el valor deseado
  if(temp&gt;=30){ // Compara si la temp ya es 30 grados
    digitalWrite(motor,HIGH); //Si lo es manda un 1 lógico a teavés del pin digital #12
  }
  else{
    digitalWrite(motor,LOW);// sino, manda un 0, lo que apagaría el motor
  }

  delay(2000);//valor en milisengundos para que repita el ciclo
  
}

and this is the barometric pressure code:
#include &lt;Wire.h&gt;
#include &lt;Adafruit_BMP085.h&gt;

// Connect VCC of the BMP085 sensor to 3.3V (NOT 5.0V!)
// Connect GND to Ground
// Connect SCL to i2c clock - on '168/'328 Arduino Uno/Duemilanove/etc thats Analog 5
// Connect SDA to i2c data - on '168/'328 Arduino Uno/Duemilanove/etc thats Analog 4
// EOC is not used, it signifies an end of conversion
// XCLR is a reset pin, also not used here

Adafruit_BMP085 bmp;
  
void setup() {
  Serial.begin(9600);
  if (!bmp.begin()) {
    Serial.println(&quot;Could not find a valid BMP085 sensor, check wiring!&quot;);
    while (1) {}
  }
}
  
void loop() {
    Serial.print(&quot;Temperature = &quot;);
    Serial.print(bmp.readTemperature());
    Serial.println(&quot; *C&quot;);
    
    Serial.print(&quot;Pressure = &quot;);
    Serial.print(bmp.readPressure());
    Serial.println(&quot; Pa&quot;);
    
    // Calculate altitude assuming 'standard' barometric
    // pressure of 1013.25 millibar = 101325 Pascal
    Serial.print(&quot;Altitude = &quot;);
    Serial.print(bmp.readAltitude());
    Serial.println(&quot; meters&quot;);

    Serial.print(&quot;Pressure at sealevel (calculated) = &quot;);
    Serial.print(bmp.readSealevelPressure());
    Serial.println(&quot; Pa&quot;);

  // you can get a more precise measurement of altitude
  // if you know the current sea level pressure which will
  // vary with weather and such. If it is 1015 millibars
  // that is equal to 101500 Pascals.
    Serial.print(&quot;Real altitude = &quot;);
    Serial.print(bmp.readAltitude(101500));
    Serial.println(&quot; meters&quot;);
    
    Serial.println();
    delay(500);
}
You need to write one program using elements from each block of code. There is no way the Arduino will run both programs concurrently, it will only run one or the other.  You can copy and paste them together but unless done correctly it will not work. This is why it is important to understand the code you are using.