How do i connect Temperature sensor and Thermoelectric with Heatsink fan

Hello,

I'm trying to combined Temperature sensor, Thermoelectric and Heatsink fan together. But i do not know how to connect up the circuit and the programming code. I really need help.

You need to post some details of the specific devices you are using. Also the code and circuit that you tried so far.

I’m using DS18B20 Temperature Sensor and 12V heatsink fan.

This is the Thermoelectric program code.

int peltier = 3; //The N-Channel MOSFET is on digital pin 3
int power = 0; //Power level fro 0 to 99%
int peltier_level = map(power, 0, 99, 0, 255); //This is a value from 0 to 255 that actually controls the MOSFET

void setup(){
Serial.begin(9600);

//pinMode(peltier, OUTPUT);
}

void loop(){
char option;

if(Serial.available() > 0)
{
option = Serial.read();
if(option == ‘a’)
power += 5;
else if(option == ‘z’)
power -= 5;

if(power > 99) power = 99;
if(power < 0) power = 0;

peltier_level = map(power, 0, 99, 0, 255);
}

Serial.print(“Power=”);
Serial.print(power);
Serial.print(" PLevel=");
Serial.println(peltier_level);

analogWrite(peltier, peltier_level); //Write this new value out to the port

}

And this is the DS18B20 Temperature Sensor program code.

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

// Data wire is plugged into pin 2 on the Arduino
#define ONE_WIRE_BUS 2

// Setup a oneWire instance to communicate with any OneWire devices
// (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);

void setup(void)
{
// start serial port
Serial.begin(9600);
Serial.println(“Dallas Temperature IC Control Library Demo”);

// Start up the library
sensors.begin();
}

void loop(void)
{
// call sensors.requestTemperatures() to issue a global temperature
// request to all devices on the bus
Serial.print(" Requesting temperatures…");
sensors.requestTemperatures(); // Send the command to get temperatures
Serial.println(“DONE”);

Serial.print("Temperature for Device 1 is: ");
Serial.print(sensors.getTempCByIndex(0)); // Why “byIndex”?
// You can have more than one IC on the same bus.
// 0 refers to the first IC on the wire

}

Currently, I’m trying to combine this both Thermoelectric and DS18B20 Temperature Sensor. And I do not know how to combine this both items.