I don't have a temperature sensor handy, so I used a CdS photocell circuit in lieu thereof.
const int transistorPin = 9;
int tempPin = A0;
int tempReading;
int x;
void setup()
{
pinMode(transistorPin, OUTPUT);
Serial.begin(9600);
}
void loop()
{
tempReading=analogRead(tempPin);//temperature reading
x=map(tempReading,0,100,1,5);//map the reading to change the frequency
float val = (exp(sin(millis()/1500.0*x*PI)) - 0.36787944)*108.0;//the function of breathing led
analogWrite(transistorPin, val);
}
That works, but the output is kind of wonky.
My "map" is a little different, my photocell circuit resulted a 0 - 80 range.
A photocell isn't fast, but a temperature sensor is a lot slower, they shouldn't result abrupt changes.
A photocell situation might benefit from a rolling average, to smooth things out a bit.
But, most of all, the assignment of tempPin should be A0, not 0.