user54696: Name of study: AUTOMATIC ELECTRIC FAN
We used an ultrasonic sensor for the switching on/off of our Fan and an LM35 SENSOR to control the speed regulation. 
During our experiment, we use a LED instead of a Fan before we proceed to fan. Here is our code:
Description: Codes for LM35 Sensor using LED and Arduino Uno as Microcontroller)
#define led 9
float temp;

void setup ()
{
   pinMode(led, OUTPUT);
   Serial.begin(9600);
} 

 void loop ()
{
    temp = analogRead (A0);
    temp = temp*0.48828125;
     if (temp < 31 )
  {
    digitalWrite(led, HIGH);
  } 
  else {

    digitalWrite(led, LOW);
  }
    Serial.print("TEMPERATURE: ");
    Serial.print(temp);
    Serial.print("*C");
     Serial.println();
     delay(1000);
 }   

Description: Code for ULTRASONIC SENSOR using two LED’s AND Arduinbo Uno as Microcontroller 
#define trigPin 13
#define echoPin 12
#define led 6
#define led 5
{
  digitalWrite(trigPin, LOW);
  delayMicroseconds (2);

  digitalWrite(trigPin, HIGH);
  delayMicroseconds (10);
  digitalWrite(trigPin, LOW);

  duration = pulseIn(echoPin, HIGH);
  distance = duration*0.034/2;
  if (distance < 100 )
  {
    digitalWrite(led, HIGH);
  } 
  else {

    digitalWrite(led, LOW);
  }
  Serial.print("Distance:");
  Serial.println(distance);
  Serial.print("cm");
  delay(1000);
}


user42539: You don't have two codes; the 2nd section has no setup() or loop().
If it did, then you could do this:

The stuff before setup() gets put together.
The stuff in setup() from one gets moved into the other. The empty setup() gets deleted.
The stuff in loop() from one gets moved into the other. The empty loop() gets deleted.

Take care of any duplicate names, pin assignments, etc.
Review the combined loop() code and adjust as needed to do what you want.

54696: <p>Name of study: AUTOMATIC ELECTRIC FAN</p>

<p>We used an ultrasonic sensor for the switching on/off of our Fan and an LM35 SENSOR to control the speed regulation. 
During our experiment, we use a LED instead of a Fan before we proceed to fan. Here is our code:</p>

<p>Description: Codes for LM35 Sensor using LED and Arduino Uno as Microcontroller)</p>

<pre><code>#define led 9
float temp;

void setup ()
{
   pinMode(led, OUTPUT);
   Serial.begin(9600);
} 

 void loop ()
{
    temp = analogRead (A0);
    temp = temp*0.48828125;
     if (temp &lt; 31 )
  {
    digitalWrite(led, HIGH);
  } 
  else {

    digitalWrite(led, LOW);
  }
    Serial.print("TEMPERATURE: ");
    Serial.print(temp);
    Serial.print("*C");
     Serial.println();
     delay(1000);
 }   
</code></pre>

<p>Description: Code for ULTRASONIC SENSOR using two LED’s AND Arduinbo Uno as Microcontroller </p>

<pre><code>#define trigPin 13
#define echoPin 12
#define led 6
#define led 5
{
  digitalWrite(trigPin, LOW);
  delayMicroseconds (2);

  digitalWrite(trigPin, HIGH);
  delayMicroseconds (10);
  digitalWrite(trigPin, LOW);

  duration = pulseIn(echoPin, HIGH);
  distance = duration*0.034/2;
  if (distance &lt; 100 )
  {
    digitalWrite(led, HIGH);
  } 
  else {

    digitalWrite(led, LOW);
  }
  Serial.print("Distance:");
  Serial.println(distance);
  Serial.print("cm");
  delay(1000);
}
</code></pre>
 42539: <p>You don't have two codes; the 2nd section has no setup() or loop().</p>

<p>If it did, then you could do this:</p>

<ul>
<li>The stuff before setup() gets put together.</li>
<li>The stuff in setup() from one gets moved into the other. The empty setup() gets deleted.</li>
<li>The stuff in loop() from one gets moved into the other. The empty loop() gets deleted.</li>
</ul>

<p>Take care of any duplicate names, pin assignments, etc.</p>

<p>Review the combined loop() code and adjust as needed to do what you want.</p>
