user14515: I want to program a temperature sensor with a LED using Arduino. 
the goal is to make a sensor, when the temperature is over than Temperature max, the LED turns off and when the temperature is small than temperature max we turn on the LED.
my problem is when I programed the void setup() as followed, the LED doesn't work, and when I comment Serial.begin (9600) the LED work but I cannot diplay the value of the temperature. 
void setup() {
   Serial.begin(9600);
   pinMode(tempPin, INPUT);
   pinMode(led, OUTPUT);
}

here you find my complet code:
    int tempPin = A0;   // the output pin of LM35
float Max_temp = 24.0;
int led = 1;

float  temp, cel;
void setup() {
   Serial.begin(9600);
   pinMode(tempPin, INPUT);
   pinMode(led, OUTPUT);
}
void loop() { 
      cel = readTemp(); 
  if(cel< Max_temp) {        // if temp is higher than tempMax
      digitalWrite(led, HIGH);  // turn on led
      delay(300);
     } 
     else {                    // else turn of led
       digitalWrite(led, LOW);  // turn on led
      delay(100);
  }
   Serial.print("TEMP: ");
   Serial.print(cel);      // display the temperature
   Serial.print("C ");
   Serial.println();
   delay(300);  
}

float readTemp() {  // get the temperature and convert it to celsius
  temp = analogRead(tempPin);
  return temp * 0.48828125;
}

thank you very much in advance

user26717: Your logic is backwards. Your program says if the temp is LESS THAN max then turn on the LED.
But worse than that, you should not use pin 1.  Pick any other pin.

user4143: int led = 1;

You do know that pins 0 and 1 are the serial port don't you?
Take your pick.... Either use pin 1 for the LED OR use pin 1 for the serial connection.  You can't do both!
As it says in the manual:

In addition, some pins have specialized functions:

Serial: 0 (RX) and 1 (TX). Used to receive (RX) and transmit (TX) TTL serial data. These pins are connected to the corresponding pins of the ATmega8U2 USB-to-TTL Serial chip.



14515: <p>I want to program a temperature sensor with a LED using Arduino. 
the goal is to make a sensor, when the temperature is over than Temperature max, the LED turns off and when the temperature is small than temperature max we turn on the LED.</p>

<p>my problem is when I programed the void setup() as followed, the LED doesn't work, and when I comment Serial.begin (9600) the LED work but I cannot diplay the value of the temperature. </p>

<pre><code>void setup() {
   Serial.begin(9600);
   pinMode(tempPin, INPUT);
   pinMode(led, OUTPUT);
}
</code></pre>

<p>here you find my complet code:</p>

<pre><code>    int tempPin = A0;   // the output pin of LM35
float Max_temp = 24.0;
int led = 1;

float  temp, cel;
void setup() {
   Serial.begin(9600);
   pinMode(tempPin, INPUT);
   pinMode(led, OUTPUT);
}
void loop() { 
      cel = readTemp(); 
  if(cel&lt; Max_temp) {        // if temp is higher than tempMax
      digitalWrite(led, HIGH);  // turn on led
      delay(300);
     } 
     else {                    // else turn of led
       digitalWrite(led, LOW);  // turn on led
      delay(100);
  }
   Serial.print("TEMP: ");
   Serial.print(cel);      // display the temperature
   Serial.print("C ");
   Serial.println();
   delay(300);  
}

float readTemp() {  // get the temperature and convert it to celsius
  temp = analogRead(tempPin);
  return temp * 0.48828125;
}
</code></pre>

<p>thank you very much in advance</p>
 26717: <p>Your logic is backwards. Your program says if the temp is LESS THAN max then turn on the LED.</p>

<p>But worse than that, you should not use pin 1.  Pick any other pin.</p>
 4143: <pre><code>int led = 1;
</code></pre>

<p>You do know that pins 0 and 1 are the serial port don't you?</p>

<p>Take your pick.... Either use pin 1 for the LED <em>OR</em> use pin 1 for the serial connection.  You can't do both!</p>

<p>As it says <em><a href="https://www.arduino.cc/en/Main/ArduinoBoardUno" rel="nofollow">in the manual</a></em>:</p>

<blockquote>
  <p>In addition, some pins have specialized functions:</p>
  
  <ul>
  <li>Serial: 0 (RX) and 1 (TX). Used to receive (RX) and transmit (TX) TTL serial data. These pins are connected to the corresponding pins of the ATmega8U2 USB-to-TTL Serial chip.</li>
  </ul>
</blockquote>
