Code problems with transistor

I have a temperature sensor hooked and a fan hooked up to the arduino. The objective of this is that when the temperature sensor reads above a certain number the fan shuts off. The fan is wired up through a transistor and hooked up to the arduino. The fan is also connected to a 9V power source. I have tested the wiring and everything is correct but I can’t seem to get the fan to shut off when it reads above a certain temperature. Any help would be great thanks.

const int temperatureSensor = A0;
const int fanPin = 1;
const int threshold = 56;
int temp1;

void setup (){
pinMode (fanPin,OUTPUT);
Serial.begin (9600);
}
void loop() {
int analogValue = analogRead (temperatureSensor);
temp1 = (0.0049100analogValue-50)*(9/5)+32;
Serial.println(temp1);
delay(500);
if (temp1 < threshold) {
digitalWrite(fanPin, HIGH);
}
else {
digitalWrite(fanPin, LOW);
}
}

The equation in the temp1 line is just a conversion from celcius to fahrenheit

I bet the Serial.println() only shows 32. Am I right?

The serial monitor shows the room temperature in degrees fahrenheit

Yeah, I see that now. Thought it was all going to be done in integer math. My bad.

Can you post a schematic of your setup.

const int fanPin = 1;

Pin 1 is one of the hardware serial port pins.