Project 1 – Temperature Controlled Fan with LCD

This project is looking at creating a unit that can be placed on a desk or table top that provides information regarding temperature and light levels to the user. If the temperature rises above a certain level, i.e. the user becomes hot, there is a fan that automatically comes on, blowing cool air directly on the user that is sat at the desk or table.

The inspiration for this project came from investigating a wide range of Arduino ‘instructables’ online to provide me with an insight into what is possible and ideas into what I can do.

One instructable that I came across was a USB gas detector –

http://www.instructables.com/id/Gas-detector-indicator-USB-powered-with-arduin/

 

This small project was a small hand held device with has a sensor which detected gas, and then displayed the levels of it on a small lcd screen on the device. I liked this idea because instead of just alerting someone that gas was present through a light or sound, it displayed the relative number on a screen which the person could physically see.

Another instructable that I looked at was a fan that automatically came on when someone sat at a desk, and then turned off when the person left.-

http://www.instructables.com/id/Arduino-Controlled-Personal-Fan-with-Ping-Sensor-/

 

The Arduino in this project incorporates an ultrasonic distance sensor, which takes a reading when something comes within a certain distance, and sends that reading to the Arduino to perform a function. I liked how this project operated automatically, without the user having to press anything and switch anything on.

From looking at the previous two instructables, I liked the automatic functions which they incorporated and looked into this further. I looked at a project which regulated the temperature and humidity of a greenhouse through various sensors. When the temperature fell below a certain level then a heater would come on, and if it rose above a certain temperature then a fan came on.

http://www.instructables.com/id/Arduino-Greenhouse-Control-Humidity-and-Temperatur/

 

From looking at these instructables I decided that I wanted to produce something that took a reading from a sensor, and then automatically performed a function depending on the reading from the sensor. I decided to create a project in where a desktop fan comes on automatically when the reading from a temperature sensor went above a certain level. I also decided to incorporate a light sensor as well. All of this information will be displayed on a lcd display, so the user is aware of the temperature and light level.

In order to achieve this, a parts list was drawn up regarding which parts will be needed for the project to carry out its task.

Parts list

1x arduino UNO board

1x breadboard

1x 16,2 LCD screen

1x 12v fan

1x 9v battery

1x variable resistor

2x resistors

1x light dependant resistor

1x temperature sensor

Jumper wires

Coding

Various coding was then drawn up in order to set up and run the project. The coding was split into parts, specific to each hardware part and its running. The separate parts of coding were then all combined to create the final piece, with multiple running parts.

The first code used here was to test the power to the arduino board.

LED Blink

void setup() {

// initialize digital pin 13 as an output.

pinMode(7, OUTPUT);

}

// the loop function runs over and over again forever

void loop() {

digitalWrite(7, HIGH);   // turn the LED on (HIGH is the voltage level)

delay(1000);              // wait for a second

digitalWrite(7, LOW);    // turn the LED off by making the voltage LOW

delay(1000);              // wait for a second

}

Fritz 1

A video of this working:

The next code was one that I used to test the DC motor, which would in turn be replaced by a fan. In this instance, the DC motor is playing the part of the fan. A 9V battery was also added, since this is what would be used to power the fan when added.

DC Motor

int motorPin = 3;

void setup()

{

pinMode(motorPin, OUTPUT);

Serial.begin(9600);

while (! Serial);

Serial.println(“Speed 0 to 255”);

}

void loop()

{

if (Serial.available())

{

int speed = Serial.parseInt();

if (speed >= 0 && speed <= 255)

{

analogWrite(motorPin, speed);

}

}

}

Fritz 2

A video of this working code and components:

This simple code was to test the circuit for the LCD screen. It originally was set to display “Hello World” but I changed it to read my name.

LCD Display

#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins

LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

void setup() {

// set up the LCD’s number of columns and rows:

lcd.begin(16, 2);

// Print a message to the LCD.

lcd.print(“Matthew Northfield”);

}

void loop() {

// set the cursor to column 0, line 1

// (note: line 1 is the second row, since counting begins with 0):

lcd.setCursor(0, 1);

// print the number of seconds since reset:

lcd.print(millis() / 1000);

}

Fritz 3

A video of the working code:

Once the coding for the LCD screen was established and proven to work, coding which would display the light levels and temperature from the sensors was then added.

LCD with Light and Temp

#include <LiquidCrystal.h>

int tempPin = 0;

int lightPin = 1;

//                BS  E  D4 D5  D6 D7

LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

void setup()

{

lcd.begin(16, 2);

}

void loop()

{

// Display Temperature in C

int tempReading = analogRead(tempPin);

float tempVolts = tempReading * 5.0 / 1024.0;

float tempC = (tempVolts – 0.5) * 100.0;

//         —————-

lcd.print(“Temp         C  “);

lcd.setCursor(6, 0);

lcd.print(tempC);

// Display Light on second row

int lightReading = analogRead(lightPin);

lcd.setCursor(0, 1);

//         —————-

lcd.print(“Light           “);

lcd.setCursor(6, 1);

lcd.print(lightReading);

delay(500);

}

Fritz 4

For the final piece of coding, an ‘if’ function was added in, as well as the coding for a dc motor to create a code that would turn the fan on when the temperature went over a certain level.

LCD with Light and Temp and Fan

#include <LiquidCrystal.h>

float tempC;

int tempPin = 0; //Temp sensor analog pin 0

int ledPin = 13; //led connected to pin 13

int fan1 = 2; //fan connected to pin 2

int lightPin = 1;

LiquidCrystal lcd(6, 7, 8, 9, 10, 11);

void setup() {

lcd.begin(16, 2);

Serial.begin(9600);

pinMode(ledPin, OUTPUT);

pinMode(fan1, OUTPUT);

}

void loop() {

int tempReading = analogRead(tempPin);

float tempVolts = tempReading * 5.0 / 1024.0;

float tempC = (tempVolts – 0.5) * 100.0;

lcd.print(“Temp         C  “);

lcd.setCursor(6, 0);

lcd.print(tempC);

int lightReading = analogRead(lightPin);

lcd.setCursor(0, 1);

//         —————-

lcd.print(“Light           “);

lcd.setCursor(6, 1);

lcd.print(lightReading);

delay(500);

if (tempC >27)

{

digitalWrite(ledPin, HIGH);

digitalWrite(fan1, HIGH);

}

else

{

digitalWrite(ledPin, LOW);

digitalWrite(fan1, LOW);

}

}

Fritz 5

A video for the final circuit:

Once everything was working and complete, a small box housing was made to enable it to sit on a desktop.

IMG_1903

Once situated inside its housing, the fan unit can be placed on to a desktop and be left there, running off its 9v battery. The fan will automatically come on then when the temperature reaches a certain level, and it will display this on its lcd screen. The light level is also shown on screen.

If I were to conduct this project again, I would incorporate some sort of work light or lamp, which would then come on, illuminating the desk when the light level dips below a certain number. I would also create a more aesthetically pleasing housing unit, as at the moment it is a bit ‘boxy’ and generic.

Overall I feel this part 1 project has given me an insight and basic understanding into arduino components and coding. I feel comfortable using a range of different code to provide me with different functions, depending on the components used and the intended usage. I feel I can take this knowledge and understanding and take it forward into the next part of the project (project 2).

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s