convert code 18b20 to dht11

I have the following code for 18B20 sensor for convert from analog temp. to analog voltage output but I have DHT11 can any one help me who to get or convert this code to use with DHT11.

#include <OneWire.h>
#include <DallasTemperature.h>

#define ONE_WIRE_BUS 2

OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

int MIN_TEMP = 0;
int MAX_TEMP = 50;

void setup() {



void loop() {

float temperature = getTemperature();
int voltage = temperatureToPWM(temperature);

float getTemperature()
float temperature =0;
sensors.requestTemperatures(); // Send the command to get temperatures
temperature = sensors.getTempCByIndex(0);
return temperature;

int temperatureToPWM(float temperature)
float temp=0;
float voltage = 0;
temp = temperature10;
voltage = map(temp,MIN_TEMP
return voltage;

The two sensors are not at all alike so trying to convert the code is not the route that I would take. Get a DHT11 library and use the example code from that library to develop a sketch for the DHT11.

No need for a completely new sketch.

All you really have to do is replace is the getTemperature() function where the sensor is read; and of course load the appropriate libraries.