How can I activate my DC fan when my DHT11 reaches a certain temperature?

This is my code, I've got the pin in digital pin 3, I just cant figure out for the life how to make it turn on when it reaches 27c, any help?

#include <dht.h>

dht DHT;
#define dht_apin A0
int redPin = 11; // Red LED, connected to digital pin 10
int grnPin = 10; // Green LED, connected to digital pin 9
int bluPin = 9; // Blue LED, connected to digital pin 8

void setup() {
Serial.begin(9600);
// Sets the pins as output for RGB LED
pinMode(redPin, OUTPUT);
pinMode(grnPin, OUTPUT);
pinMode(bluPin, OUTPUT);
}

void loop() {
int chk = DHT.read11(dht_apin);
int t = DHT.temperature;
int h = DHT.humidity;
Serial.print("Current humidity = ");
Serial.print(DHT.humidity);
Serial.print("% ");
Serial.print("temperature = ");
Serial.print(DHT.temperature);
Serial.println("C ");
delay(5000);
if((DHT.temperature < 40) && (DHT.temperature >= 27.2)) {
// Writing the LED colour pins HIGH or LOW to set colours
digitalWrite(redPin, HIGH); // yellow
digitalWrite(grnPin, HIGH);
delay(100);
digitalWrite(bluPin, LOW);
}
if((DHT.temperature < 27) && (DHT.temperature > 23.2)) {
digitalWrite(grnPin, HIGH); // green
delay(100);
digitalWrite(redPin, LOW);
digitalWrite(bluPin, LOW);
}
if((DHT.temperature < 23) && (DHT.temperature > 17.2)) {
digitalWrite(grnPin, HIGH); // aqua
digitalWrite(bluPin, HIGH);
delay(100);
digitalWrite(redPin, LOW);
}
if(DHT.temperature <= 17) {
digitalWrite(bluPin, HIGH); // blue
delay(100);
digitalWrite(grnPin, LOW);
digitalWrite(redPin, LOW);
}
delay(1000);
// Sensor shouldn't be read too frequently so delay of 1s
}

what do you see on the Serial output?

Note that if you are unlucky and the temperature is 17.1° when you start or 23.1° or 27.1° and stays there then you won't get any LED turned on. same if it's more than 40°

Side question: is your RGB LED common anode or cathode ? did you use current limiting resistors ?

(and you could use If-else instead of separated ifs).


Please correct your post above and add code tags around your code:
[code]`` [color=blue]// your code is here[/color] ``[/code].

It should look like this:// your code is here
(Also press ctrl-T (PC) or cmd-T (Mac) in the IDE before copying to indent your code properly)