DHT11 to trigger relay

i have a temp and humidity sensor…

/*####################################################################
 FILE: dht11_functions.pde - DHT11 Usage Demo.
 VERSION: 2S0A

 PURPOSE: Measure and return temperature & Humidity. Additionally provides conversions.

 LICENSE: GPL v3 (http://www.gnu.org/licenses/gpl.html)
 GET UPDATES: https://www.virtuabotix.com/

      --##--##--##--##--##--##--##--##--##--##--
      ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##
      ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##
      | ##  ##  ##  ##  ##  ##  ##  ##  ##  ## |
      ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##
      ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##
      | ##  ##  ##  ##  ##  ##  ##  ##  ##  ## |
      ##  ##  ##  ## DHT11 SENSOR ##  ##  ##  ##
      ##  ##  ##  ##  ##FRONT ##  ##  ##  ##  ##
      | ##  ##  ##  ##  ##  ##  ##  ##  ##  ## |
      ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##
      ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##
      | ##  ##  ##  ##  ##  ##  ##  ##  ##  ## |
      ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##
      ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##
      --##--##--##--##--##--##--##--##--##--##--
          ||       ||          || (Not    ||
          ||       ||          || Used)   ||
        VDD(5V)   Readout(I/O)          Ground

  HISTORY:
  Joseph Dattilo (Virtuabotix LLC) - Version 2S0A (27 May 12)
  -Rewritten to with more powerful Versalino functionality
  Joseph Dattilo (Virtuabotix LLC) - Version 0.4.5 (11/11/11)
  -Made Library Arduino 1.0 Compatible
  Joseph Dattilo (Virtuabotix LLC) - Version 0.4.0 (06/11/11)
  -Fixed bugs (squish)
  Mod by Rob Tillaart - Version 0.3 (28/03/2011)
  Mod by SimKard - Version 0.2 (24/11/2010)
 George Hadjikyriacou - Original version (??)
#######################################################################*/


#include <dht11.h>

dht11 DHT11;

void setup()
{
  DHT11.attach(2);
  Serial.begin(9600);
  Serial.println("DHT11 TEST PROGRAM ");
  Serial.print("LIBRARY VERSION: ");
  Serial.println(DHT11LIB_VERSION);
}

void loop()
{
  Serial.println("\n");

  int chk = DHT11.read();

  Serial.print("Read sensor: ");
  switch (chk)
  {
    case 0: Serial.println("OK"); break;
    case -1: Serial.println("Checksum error"); break;
    case -2: Serial.println("Time out error"); break;
    default: Serial.println("Unknown error"); break;
  }

  Serial.print("Humidity (%): ");
  Serial.println((float)DHT11.humidity, DEC);

  Serial.print("Temperature (°C): ");
  Serial.println((float)DHT11.temperature, DEC);

  Serial.print("Temperature (°F): ");
  Serial.println(DHT11.fahrenheit(), DEC);



  delay(500);
}

this is my current code, everything is working just fine, the readings is responsive, i just don’t know how to add a code to set pwm when it reaches temperature(celsius) less than 18degrees celsius or what preferrable temperature that is uncomfortable enough for someone to work in the cold for a long time… i"ll be the one to work on that.

the pwm will control the amount of heat my heating element will produce.

i chose pwm as output because i wanted the heating element to warm up gradually,

please help me on this one…

if temp celsius is = or <18

set pwm to increase gradually 0-255
for 5 seconds and hold it to 255

if temp celsius is > 18

set pwm to decrease gradually 255-0

i’m open to suggestions!!!

Well, you already have acceptable pseudo code. What is your problem, exactly? Couldn’t you gain something from similar examples and tutorials? It seems like you just need to learn to code in C++.

i don't know how to code it....

iceratio:
if temp celsius is = or <18

if (DHT11.temperature <= 18)

… and so forth…
Just learn C++.

i just don't know how to add a code to set pwm when

PWM-ing a relay is NOT a good idea.

i used a transistor as a relay....

iceratio: i used a transistor as a relay....

Connect to a pin in a variable called ledPin, no doubt.