Temperature Finder is not working!!

For some reason, my temperature finder isn’t working. The serial monitor doesn’t change the Celsius reading at all. To top it off, every time I turn it on, the temperature reads 365ºC! Why is it not working?
Here is my code: Its the exact same to the Arduino Uno Starter projects book.

const int sensorPin = A0;
const float baselineTemp = 20.0;
void setup() {

  • Serial.begin(9600); //open serial port*

  • for (int pinNumber = 2; pinNumber < 5; pinNumber++){*

  • pinMode(pinNumber, OUTPUT);*

  • digitalWrite(pinNumber, LOW);*

  • }*
    }
    void loop() {

  • int sensorVal = analogRead(sensorPin);*

  • Serial.print("Sensor Value: ");*

  • Serial.print(sensorVal);*
    _ float voltage = (sensorVal/1024.0) * 5.0;_

  • Serial.print(", Volts: ");*

  • Serial.print(voltage);*

  • Serial.print(", degrees C: ");*
    _ float temperature = (voltage - .5) * 100;_

  • Serial.println(temperature);*

  • if(temperature < baselineTemp) {*

  • digitalWrite(2,LOW);*

  • digitalWrite(3,LOW);*

  • digitalWrite(4,LOW);*

  • }*

  • if(temperature >= baselineTemp && temperature < baselineTemp + 5) {*

  • digitalWrite(2,HIGH);*

  • digitalWrite(3,LOW);*

  • digitalWrite(3,LOW);*

  • }*

  • if(temperature >= baselineTemp+5 && temperature < baselineTemp + 10) {*

  • digitalWrite(2,HIGH);*

  • digitalWrite(3,HIGH);*

  • digitalWrite(3,LOW);*

  • }*

  • if(temperature >= baselineTemp+10 && temperature < baselineTemp + 15) {*

  • digitalWrite(2,HIGH);*

  • digitalWrite(3,HIGH);*

  • digitalWrite(3,HIGH);*

  • }*

  • delay(50);*
    }

I hope

Are you using a TMP 36 temperature sensor?

If you have the 5v Vs and Gnd reversed, it will get very hot.

I just found out that the book is wrong. In front of the temp finder, I need to place a capacitor. Now its working normally.

YYYYYYAAAAAAAAYYYYYY!