Merging 3 sketches NOOB ALERT!

Thank you Robin. I believe I have made a very small amount of progress. However, now the MOSFET (switching a motor) starts up and just continues running.. :frowning:

I've attached my code that I have tried my best with.

It makes perfect sense now what you are all saying.

#include <dht.h>
#define dht_apin A0 // Analog Pin sensor is connected to
 
int ledPin = 13;

int MOSFETPin = 8;                // choose the pin for the MOSFET

int pirPin = 2;               // PIR input pin (for PIR sensor)
int pirState = LOW;             // we start, assuming no motion detected
int pir = 0;                    // variable for reading the pin status

int micPin=7;                // microphone input pin
boolean value =0;

int tempPin=A0;                // Temperature input pin
boolean val =0; 

dht DHT;
 
void setup() {
  pinMode (ledPin, OUTPUT);
  pinMode(MOSFETPin, OUTPUT);      // declare MOTOR as output
  pinMode(pirPin, INPUT);     // declare PIR sensor as input
  
  pinMode(micPin, INPUT);   // declare microphone input

  pinMode(tempPin, INPUT);
  Serial.begin(9600);
  delay(500);                  //Delay to let system boot
  Serial.println("DHT11 Humidity & temperature Sensor\n\n");
  delay(1000);                //Wait before accessing Sensor
 
  Serial.begin(9600);
}
 
void loop(){

      // Start of PIR sensor
  pir = digitalRead(pirPin);  // read input value
  if (pir == HIGH) {            // check if the input is HIGH
    digitalWrite(MOSFETPin, HIGH);  // turn motor on
    delay (5000);                  // leave running for 5 seconds
    digitalWrite(MOSFETPin, LOW);   // turn motor off
    if (pirState == LOW) {
      // we have just turned on
      Serial.println("Motion detected!");
      // We only want to print on the output change, not state
      pirState = HIGH;
    }
  } else {
    digitalWrite(MOSFETPin, LOW); // turn LED OFF
    if (pirState == HIGH){
      // we have just turned of
      Serial.println("Motion ended!");
      // We only want to print on the output change, not state
      pirState = LOW;
    }
  }


  
   // Start of Mic program
   value =digitalRead(micPin);
  Serial.println (value);
  // when the sensor detects a signal above the threshold value, LED flashes
  if (value==HIGH) {
    digitalWrite(MOSFETPin, HIGH);
    delay (5000);
    digitalWrite(MOSFETPin, LOW);
  }
  else {
    digitalWrite(MOSFETPin, LOW);



    //Start of Temp Program 
   val =digitalRead(tempPin);
  Serial.println (val);
  // when the sensor detects a signal above the threshold value, LED flashes
  if (val==HIGH) {
    digitalWrite(ledPin, HIGH);
  }
  else {
    digitalWrite(ledPin, LOW);
  }
    DHT.read11(dht_apin);
    
    Serial.print("Current humidity = ");
    Serial.print(DHT.humidity);
    Serial.print("%  ");
    Serial.print("temperature = ");
    Serial.print(DHT.temperature); 
    Serial.println("C  ");
    
    delay(5000);//Wait 5 seconds before accessing sensor again.
 
  //Fastest should be once every two seconds.


    
  }
}