Breathing LED controlled by temperature sensor (NEED HELP!!)

PaulRB:
I based this on the version you gave in the very first post:

#include <math.h>

const int transistorPin = 9;
int tempPin = 0;
int tempReading;
int x;
float angle = 0;

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

void loop()
{
  tempReading=analogRead(tempPin);//temperature reading
  x=map(tempReading,150,170,1,5);//map the reading to change the frequency
  Serial.println(x);
  angle += 20.0/1500.0xPI;
  float val = (exp(sin(angle)) - 0.36787944)*108.0;//the function of breathing led
  Serial.println(val);
  analogWrite(transistorPin, val);
  delay(20);

}

Thank you so much!!!!! IT WORKS!!
I add a smooth code, It works flawlessly now!!!
Here is the code.

const int numReadings = 50;

int readings[numReadings];      // the readings from the analog input
int index = 0;                  // the index of the current reading
int total = 0;                  // the running total
int average = 0;

const int transistorPin = 9;
int tempPin = 0;
int tempReading;
int x;
float angle = 0;

void setup()
{
  pinMode(9, OUTPUT); 
  Serial.begin(9600); 
  for (int thisReading = 0; thisReading < numReadings; thisReading++)
    readings[thisReading] = 0;    
}

void loop()
{
  tempReading=analogRead(tempPin);//temperature reading
    total= total - readings[index];         
  // read from the sensor:  
  readings[index] = analogRead(tempReading); 
  // add the reading to the total:
  total= total + readings[index];       
  // advance to the next position in the array:  
  index = index + 1;                    

  // if we're at the end of the array...
  if (index >= numReadings)              
    // ...wrap around to the beginning: 
    index = 0;                           

  // calculate the average:
  average = total / numReadings;         
  // send it to the computer as ASCII digits
  Serial.println(average);   
  delay(1);  
  x=map(average,155,175,1,10);//map the reading to change the frequency
  Serial.println(average);
  angle += 20.0/2000.0*x*PI;
  float val = (exp(sin(angle)) - 0.36787944)*108.0;//the function of breathing led
  
  analogWrite(transistorPin, val);
  delay(20);

}