Making Things Interactive

March 7, 2008

Automated Window Opener

Filed under: 7: Mid-Term Project, Brian Kish — bkish @ 1:54 am

http://www.youtube.com/watch?v=C_Zslar5zkg

My goal is to created a completely automated wall system that helps to control the temperature in the space. In the long term, I hope also have automated louvers that will be controlled by both light and temperature. Unfortunately, I burned out one of my servos and got a couple from the robotics club. However, I guess they modified them by taking out the potentiometer and restricting pins so the they can continually rotate. It took me a long time to try and get them to move back and forth before I figured out that you couldn’t!

For this portion, I am using a linear actuator to open and close a window (the window is still imaginary). It is controlled by the indoor and outdoor temperature. It three conditions and 2 states:

if ((tempOUT >= 65) && (tempIN >=65)) THEN WINDOW OPEN!! (RED LED)

else if ((tempOUT < 65) && (tempIN < 80)) THEN WINDOW CLOSE!! (BLUE LED)

else if ((tempOUT < 65) && (tempIN >=80)) THEN WINDOW OPEN!! (RED LED)

I used an ice-pack to change the temperature in the sensors to verify that the system worked. It works.

Circuit Diagram:

Circuit Diagram

All the Components:
Components of Project

THE LM35 TEMPERATURE SENSOR:

LM35 Temperature Sensor

/*
Temp sensor code for automated window opener.  The sensor used is an amplified LM35.
*/
int tempoutPin = 0;				    //input read pin for LM35 is Analog Pin 0
int tempinPin = 1;                                  //input read pin for LM35 is Analog Pin 1
float tempIN = 0;			            //variable which will be calculated in process
float tempOUT = 0;                                  //variable which will be calculated in process
int redLED=5;					    //Pin5 = Red LED
int blueLED=7;				            //Pin7 = Blue LED
int greenLED=6;    				    //Pin6 = Green LED
long val=0;					    //variable to store the value coming from the sensor
int openWINpin = 3;                                 // H-bridge leg 1 set to open window
int closeWINpin = 4;                                // H-bridge leg 2 set to close window
int speedPin = 9;                                   // H-bridge enable pin

void setup()
{
pinMode(redLED, OUTPUT);			    //redLED set to output
pinMode(greenLED, OUTPUT);			    //greenLED set to output
pinMode(blueLED, OUTPUT);			    //blueLED set to output
pinMode(openWINpin, OUTPUT);                      //openWINpin set to output
pinMode(closeWINpin, OUTPUT);                     //closeWINpin set to output
pinMode(speedPin, OUTPUT);                        //speedPin set to output
pinMode(tempoutPin, INPUT);                       //tempoutPin set to input
pinMode(tempinPin, INPUT);                        //tempinPin set to output
Serial.begin(9600);                               // Stars Serial Communication
digitalWrite(speedPin, HIGH);                     // sets speed to on for Actuator
}

void loop ()					   //loop below process
{

Serial.println("Outdoor Temperature is   ");	   //Print "Outdoor Temperature is" every loop
val = analogRead(tempoutPin);		           //read the value of sensor
tempOUT = (32+9*val*10/1024);	                   //convert voltage to temperature (farenheit)
Serial.println ((long)tempOUT);	           //print temperature value on serial screen
Serial.println ("Degrees Farenheit");            //Print "Degrees Farenheit" every loop

Serial.println("Indoor Temperature is   ");	  //Print "Indoor Temperature is" every loop
val = analogRead(tempinPin);		          //read the value of sensor
tempIN = (32+9*val*10/1024);	                  //convert voltage to temperature
Serial.println ((long)tempIN);	          //print temperature value on serial screen
Serial.println ("Degrees Farenheit");           //Print "Degrees Farenheit" every loop

if ((tempOUT >= 65) && (tempIN >=65))		  //Check if temp over x degrees C.
{
digitalWrite (redLED, HIGH);		  //If so... turn LED on
digitalWrite (blueLED, LOW);	          //and this LED off
digitalWrite (greenLED, LOW);	          //and this LED off
digitalWrite(openWINpin, HIGH);               // set leg 1 of the H-bridge low
digitalWrite(closeWINpin, LOW);               // set leg 2 of the H-bridge high

}
else if ((tempOUT < 65) && (tempIN >=80))       //if temperature does not meet above requirement but is between Y and Z... do below
{
digitalWrite (redLED, LOW);		          //turn LED off
digitalWrite (blueLED, HIGH);	          //turn LED on
digitalWrite (greenLED, LOW);	          //turn LED off
digitalWrite(openWINpin, HIGH);               // set leg 1 of the H-bridge low
digitalWrite(closeWINpin, LOW);               // set leg 2 of the H-bridge high
}
else if ((tempOUT < 65) && (tempIN < 80))      //if temperature does not meet above requirement but is between Y and Z... do below
{
digitalWrite (redLED, LOW);		         //turn LED off
digitalWrite (blueLED, LOW);	         //turn LED off
digitalWrite (greenLED, HIGH);	         //turn LED on
digitalWrite(openWINpin, LOW);               // set leg 1 of the H-bridge low
digitalWrite(closeWINpin, HIGH);             //set leg 2 of the H-bridge high
}

delay(5000);					 //wait for 5 seconds

}						  //End of process, go back to start of loop - ie check temp...

Blog at WordPress.com.