Tuesday, 16 June 2015

Controlling home appliances wireless......!!!

Hiiiii frnds ...today iam with new prototype . i.e remote controlling of home appliances..this can control almost all electrical appliances using some common wireless technologies like
IR remote control
DTMF based controlling..
Tools I used here for developing this project is arduino ide..
Components for this project are
Atmega328p ic's( one for IR and other for DTMF)
Tsop sensor
DTMF decoder which I used in earlier post
Relays (as many appliances)
16x2 lcd's (optional)

Below is the code for both IR and DTMF

//for DTMF
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(6, 7, 5, 4, 3, 2);

void setup()
{
pinMode(9,INPUT);
pinMode(10,INPUT);
pinMode(11,INPUT);
pinMode(12,INPUT);
pinMode(A5,OUTPUT);
pinMode(A4,OUTPUT);
pinMode(A3,OUTPUT);
pinMode(A2,OUTPUT);
                                                                   // set up the LCD's number of columns and rows: 
  lcd.begin(16, 2);
                                                                   // Print a message to the LCD.
  lcd.print("Initilizing.");
  delay(1000);
  lcd.print(".");
  delay(1000);
  lcd.print(".");
  delay(1000);
  lcd.print(".");
delay(100);
lcd.clear();
}
void loop()
{
  int a,b,c,d;
a=digitalRead(9);
b=digitalRead(10);
c=digitalRead(11);
d=digitalRead(12);

if (a==0&&b==0&&c==0&&d==1)
{
  digitalWrite(A5,1);
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("light 1 is ON");
}
else if(a==0&&b==0&&c==1&&d==0)
{
  digitalWrite(A5,0);
   lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("light 1 is OFF");
}
else if(a==0&&b==1&&c==0&&d==0)
{
  digitalWrite(A4,1);
    lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("light 2 is ON");
}
else if(a==0&&b==1&&c==0&&d==1)
{
  digitalWrite(A4,0);
      lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("light 2 is OFF");
}
  else if(a==0&&b==1&&c==1&&d==1)
{
  digitalWrite(A3,1);
      lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("light 3 is ON");
}
  else if(a==1&&b==0&&c==0&&d==0)
{
  digitalWrite(A3,0);
      lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("light 3 is OFF");
}
delay(200);
}



Similarly for IR
#include <LiquidCrystal.h>


#include <IRremote.h>

int RECV_PIN = 8;

IRrecv irrecv(RECV_PIN);

decode_results results;
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(6, 7, 5, 4, 3, 2);

void setup()
{
Serial.begin(9600);
 pinMode(8,INPUT);
pinMode(A5,OUTPUT);
pinMode(A4,OUTPUT);
pinMode(A3,OUTPUT);
pinMode(A2,OUTPUT);
 irrecv.enableIRIn(); // Start the receiver
 // set up the LCD's number of columns and rows: 
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.print("Initilizing.");
  delay(1000);
  lcd.print(".");
  delay(1000);
  lcd.print(".");
  delay(1000);
  lcd.print(".");
  delay(1000);
  lcd.clear();
  
}
void loop()
{
 
 if (irrecv.decode(&results))
 {  
  if(results.value==0x249815D2)
   {
   digitalWrite(A5,1);
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("light 1 is ON");
}
else if((results.value==0x9D2AE0F2))
{
  digitalWrite(A5,0);
   lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("light 1 is OFF");
}
else if((results.value==0x5D674052))
{
  digitalWrite(A4,1);
    lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("light 2 is ON");
}
else if((results.value==0x3B9E84E))
{
  digitalWrite(A4,0);
      lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("light 2 is OFF");
}
  else if((results.value==0xBED4BC32))
{
  digitalWrite(A3,1);
      lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("light 3 is ON");
}
  else if((results.value==0x232917F2))
{
  digitalWrite(A3,0);
      lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("light 3 is OFF");
}
 irrecv.resume();
 }
delay(200);
}
 

NOTE: different remotes will get different hex values so keep in mind to change those values.



Some pics of project....

No comments:

Post a Comment