Temperature Triggered Fan

by Aayanso in Circuits > Arduino

34 Views, 0 Favorites, 0 Comments

Temperature Triggered Fan

IMG_2214.JPG

This instructable details how to build a fan that is triggered by a push button & temperature sensor, I mainly took inspiration from some of the examples shown in class, and it led me to create a circuit designed to cool down the surrounding area.

Supplies

Basic Wiring

IMG_2181.JPG

I wired the temperature sensor, push button and LED first, connecting the sensor to pin 2, the push button connected to pin 4, and the RGB LED connected to PWM pins, pins 9, 10, and 11 (PWM pins have a ~ next to them)


You'll see an H-bridge in that breadboard because I originally wanted to use a DC motor and H-bridge as a fan, but it didn't work out.

Coding & Libraries

On the Arduino end, I needed to install libraries for the DHT sensor, DHT sensor library and Adafruit_Sensor and I followed code from Utsource's instructable


I ended up using the following lines of code

#include "DHT.h"
#define DHTPIN 7 // pin DHT sensor is connected to
#define DHTTYPE DHT11 // DHT 11
int redPin = 9;
int greenPin = 6;
int bluePin = 7;
int button = 4;
int buttonState = 0;
int fan = 3;
void setColor(int red, int green, int blue)
{
analogWrite(redPin, red);
analogWrite(greenPin, green);
analogWrite(bluePin, blue);
}
// Initialize DHT sensor
DHT dht(DHTPIN, DHTTYPE);

void setup()
{
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);
Serial.begin(9600);
dht.begin();
}

void loop()
{
delay(250);
temp = dht.readTemperature();
if (buttonState == HIGH && temp > 15)
{
setColor(0,255,0);
digitalWrite(fan, LOW);
}
else {
setColor(255,0,0);
digitalWrite(fan, HIGH);
}
}

DC Motor, Who?

IMG_2214 (1).JPG

I connected the computer fan by having 2 pins attached to a 9V battery, and the third pin was connected to a digital pin on the Arduino, as the H-bridge and DC motor I was planning to use ended up redundant and never worked because the motor was either drawing too much power or some other problem.

Schematic

Screenshot 2024-06-21 123843.png

How It's All Supposed to Come Together

Downloads