I am having problems writing the code for a temp controlled fan

My circuit consists of a temperature sensor, potentiometer, transistor and motor, led, push switch.
How it is meant to work: The Arduino reads the temp sensor (pinA0) and if it is above 25 degrees celcius, it turns the LED (pin13) and fan (pin3) HIGH, if it drops below 25 the fan and LED is LOW. I wired the potentiometer to control speed of fan so I don't think i have to write the potentiometer into the code!!!??? Push switch (Pin2) will test the Fan and LED.
I know there is something wrong in the "void loop" section but i am very inexperienced and need some expert guidance.

The code:
[
float tempC;
int tempPin = 0; // Attach vout to analog pin.
int ledPin = 13; // attach led to pin 13.
int fanPin = 3; // attach base of transistor to digital pin 3.
int inputPin = 2;
int val = 0;

void setup() // Will execute once at the start of the code.
{
Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
pinMode (ledPin, OUTPUT); // sets the led pin 13 up as an output.
pinMode (fanPin, OUTPUT); // sets the fan1 pin 3 up as an output.
pinMode(inputPin, INPUT); // declare pushbutton as input
pinMode(tempPin, INPUT);
}

void loop()
{
val = digitalRead(inputPin);
tempC = analogRead(tempPin);
tempC = (tempC * 100.0)/1024.0;
Serial.println(tempC);
if (tempC > 25)
{
digitalWrite (ledPin, HIGH); // turns on led.
digitalWrite (fanPin, HIGH); // turns on fan1.

}
else
{
digitalWrite (ledPin, LOW); // turns off led.
digitalWrite (fanPin, LOW); // turns off fan1.
}
val = digitalRead(inputPin);
if (val == HIGH) {
digitalWrite(fanPin, HIGH); // test on fan
digitalWrite(ledPin, HIGH);
}
else
{
digitalWrite (ledPin, LOW);
digitalWrite(fanPin, LOW); // turn Fan off
}
delay(1000); // wait seconds before redoing the loop.

}

]

Any help would be greatly appreciated

DSC_0063[1].jpg

float tempC;
int tempPin = 0;                        // Attach vout to analog pin.
int ledPin = 13;                           // attach led to pin 13.
int fanPin = 3;      // attach base of transistor to digital pin 3.
int inputPin = 2;
int val = 0;

void setup()                            // Will execute once at the start of the code.
{
  Serial.begin(9600);                   // opens serial port, sets data rate to 9600 bps
  pinMode (ledPin, OUTPUT);                // sets the led pin 13 up as an output.
  pinMode (fanPin, OUTPUT);          // sets the fan1 pin 3 up as an output.
  pinMode(inputPin, INPUT);          // declare pushbutton as input
  pinMode(tempPin, INPUT);
}

void loop()                           
{
  val = digitalRead(inputPin);
  tempC = analogRead(tempPin);
  tempC = (tempC * 100.0)/1024.0;
  Serial.println(tempC);
  if ((tempC > 25) || (val==HIGH))
  {                                           
    digitalWrite (ledPin, HIGH);         // turns on led.
    digitalWrite (fanPin, HIGH);        // turns on fan1.
  }
  else                             
  {
    digitalWrite (ledPin, LOW);          // turns off led.
    digitalWrite (fanPin, LOW);         // turns off fan1.
  }
  delay(100);                          // wait seconds before redoing the loop.
}

thisisbollox:

int tempPin = 0;  // Attach vout to analog pin.You’re attaching DIGITAL PIN 0 here. Try:int tempPin = A0;  // Attach vout to analog pin.

The compiler accept both, but I agree. For readability: use A0

What is is not doing that it should, or doing that it shouldn't?

You don't need to use pinMode() to initialise an analog input pin for use as an analog input pin. Doing so for pin 0 might interfere with serial I/O but shouldn't affect the rest of the logic controlling the LED and motor outputs.

The rest of the code looks credible. You aren't enabling the internal pull-up resistor for the switch input, and the code suggests you're expecting it to be active high. Do you have an external pull-down resistor connected to pin 2?

I suggest you leave the fan pin disconnected for now while you sort out the logic, and just use the LED for testing. Once you have the LED control working correctly, work out how much current you need to drive the LED and transistor and check whether you actually need two output pins, given that they are always outputting the same state.