Thumb a372872a abd8 48d5 a61b 55e5016df5b1

SMART WINDOW

1. Smart window can be operated through android app with servo operated open and close feature. 2. It can sense rain, wind and temperature and shuts the window to maintain better environment inside the house.

Project State

Public Project

Licences

Software Licence: Creative Commons Attribution Share-Alike license
Hardware Licence: Creative Commons Attribution Share-Alike license

Project Tags

Admins

Himanshu_S

Members

Sweta_Asthana

Does this project pique your interest?

Login or register to join or follow this project.

This project is a part of Smart Home Project, Click here to see overview and dependencies

Watch Video Here

This project is related to smart window which can be controlled by mobile phone using android mobile app.

The window is also Smart enough to detect Rain and fast moving air.

Below is the code for arduino to control smart window.

The Code :-

#include 
#include  
 #include  
Servo servo1;
Servo servo2;// create servo objects to control a servo 
                // twelve servo objects can be created on most boards
boolean WindowStatus = 0; // status of window i.e open = 1 and close = 0
boolean DoorStatus = 0; // status of door i.e open = 1 and close = 0
int pos = 0;    // variable to store the servo position 
 SoftwareSerial mySerial(9, 10);
void setup() 
{ 
 mySerial.begin(9600);   // Setting the baud rate of DOOR controller
 Serial.begin(9600);    // Setting the baud rate of Switch board controller
 servo1.attach(5); // attaches the servo on pin 5 to the servo object 
 servo2.attach(6);  // attaches the servo on pin 6 to the servo object 
 pinMode(13, INPUT_PULLUP); // switch to open/close window
 WindowStatus=EEPROM.read(0);
 pinMode(A0, INPUT_PULLUP);
  pinMode(2, INPUT_PULLUP);
  pinMode(3, INPUT_PULLUP);
  pinMode(4, INPUT_PULLUP);
   pinMode(11, OUTPUT);
   pinMode(12, OUTPUT);
 } 
 
void loop() 
{ 
  if( digitalRead(13)==0 && WindowStatus == 0 ){
 for(pos = 150; pos >= 65; pos -= 1) // goes from 150 degrees to 65 degrees 
 {                                  // in steps of 1 degree 
    servo2.write(pos);              // tell servo to go to position in variable 'pos' 
    delay(15);                       // waits 15ms for the servo to reach the position 
  }
  for(pos = 60; pos <= 155; pos += 1) // goes from 60 degrees to 155 degrees 
 {                                  // in steps of 1 degree 
    servo1.write(pos);              // tell servo to go to position in variable 'pos' 
    delay(15);                       // waits 15ms for the servo to reach the position 
  }
  
  WindowStatus = 1;
  EEPROM.write(0, WindowStatus);
  } 
  

  if( digitalRead(13)==0 && WindowStatus == 1 ){
 for(pos = 155; pos >= 60; pos -= 1) // goes from 155 degrees to 60 degrees 
 {                                  // in steps of 1 degree 
    servo1.write(pos);              // tell servo to go to position in variable 'pos' 
    delay(15);                       // waits 15ms for the servo to reach the position 
  }
  for(pos = 65; pos <= 150; pos += 1) // goes from 60 degrees to 150 degrees 
 {                                  // in steps of 1 degree 
    servo2.write(pos);              // tell servo to go to position in variable 'pos' 
    delay(15);                       // waits 15ms for the servo to reach the position 
  }
  WindowStatus = 0;
  EEPROM.write(0, WindowStatus);
  } 



  // Open close window using bluetooth app
 if (Serial.available()>0)  
 { char ch = Serial.read(); // Input from bluetooth module
if( ch == 'G' && WindowStatus == 0 ){
 for(pos = 150; pos >= 65; pos -= 1) // goes from 150 degrees to 65 degrees 
 {                                  // in steps of 1 degree 
    servo2.write(pos);              // tell servo to go to position in variable 'pos' 
    delay(15);                       // waits 15ms for the servo to reach the position 
  }
  for(pos = 60; pos <= 155; pos += 1) // goes from 60 degrees to 155 degrees 
 {                                  // in steps of 1 degree 
    servo1.write(pos);              // tell servo to go to position in variable 'pos' 
    delay(15);                       // waits 15ms for the servo to reach the position 
  }
  
  WindowStatus = 1;
  EEPROM.write(0, WindowStatus);
  } 
  

  if( ch == 'g' && WindowStatus == 1 ){
 for(pos = 155; pos >= 60; pos -= 1) // goes from 155 degrees to 60 degrees 
 {                                  // in steps of 1 degree 
    servo1.write(pos);              // tell servo to go to position in variable 'pos' 
    delay(15);                       // waits 15ms for the servo to reach the position 
  }
  for(pos = 65; pos <= 150; pos += 1) // goes from 60 degrees to 150 degrees 
 {                                  // in steps of 1 degree 
    servo2.write(pos);              // tell servo to go to position in variable 'pos' 
    delay(15);                       // waits 15ms for the servo to reach the position 
  }
  WindowStatus = 0;
  EEPROM.write(0, WindowStatus);
  } 
}




  if( analogRead(A0) < 600 && WindowStatus == 1 ){   // Rain Sensor
 for(pos = 155; pos >= 60; pos -= 1) // goes from 155 degrees to 60 degrees 
 {                                  // in steps of 1 degree 
    servo1.write(pos);              // tell servo to go to position in variable 'pos' 
    delay(15);                       // waits 15ms for the servo to reach the position 
  }
  for(pos = 65; pos <= 150; pos += 1) // goes from 60 degrees to 150 degrees 
 {                                  // in steps of 1 degree 
    servo2.write(pos);              // tell servo to go to position in variable 'pos' 
    delay(15);                       // waits 15ms for the servo to reach the position 
  }
  WindowStatus = 0;
  EEPROM.write(0, WindowStatus);
  } 



 if( analogRead(A1) > 150 && WindowStatus == 1 ){  // Wind Sensor
 for(pos = 155; pos >= 60; pos -= 1) // goes from 155 degrees to 60 degrees 
 {                                  // in steps of 1 degree 
    servo1.write(pos);              // tell servo to go to position in variable 'pos' 
    delay(15);                       // waits 15ms for the servo to reach the position 
  }
  for(pos = 65; pos <= 150; pos += 1) // goes from 60 degrees to 150 degrees 
 {                                  // in steps of 1 degree 
    servo2.write(pos);              // tell servo to go to position in variable 'pos' 
    delay(15);                       // waits 15ms for the servo to reach the position 
  }
  WindowStatus = 0;
  EEPROM.write(0, WindowStatus);
  } 
 


if (mySerial.available()>0)    
 { char ch = mySerial.read(); 
if ( ch == 'Z')
Serial.write('Z'); // Switch OFF lights
if ( ch == 'Y'){     // Close Door
if( DoorStatus==1){
  while(digitalRead(3)==HIGH){
    digitalWrite(11, LOW);
    digitalWrite(12, HIGH);
  }
 digitalWrite(11, LOW);
    digitalWrite(12, LOW); 
  DoorStatus=0;
}

}
}


if(digitalRead(4)==LOW && DoorStatus==0){   // Open Door
  while(digitalRead(2)==HIGH){
    digitalWrite(11, HIGH);
    digitalWrite(12, LOW);
  }
 digitalWrite(11, LOW);
    digitalWrite(12, LOW); 
  DoorStatus=1;
}
if(digitalRead(4)==LOW && DoorStatus==1){ // Close Door
  while(digitalRead(3)==HIGH){
    digitalWrite(11, LOW);
    digitalWrite(12, HIGH);
  }
 digitalWrite(11, LOW);
    digitalWrite(12, LOW); 
  DoorStatus=0;
}
}

Comments