HOME AUTOMATION WITH IR-RECEIVER AND REMOTE || MKinventions

HOME AUTOMATION WITH 

IR-RECEIVER AND REMOTE





CIRCUIT DIAGRAM:



COMPONENTS REQUIRED:

1. ARDUINO UNO/NANO.
2. IR-RECEIVER DIODE.
3. ANY IR-REMOTE.
4. RELAY BOARD ( 4 CHANNEL ).
5. JUMPER WIRES.
6. MOBILE .


LIBRARY:


(OR)
open ARDUINO goto SKETCH   => INCLUDE LIBRARY  =>  MANAGE LIBRARIES => type IRremote install library 


SOURCE CODE:

A. IR-REMOTE DECODER CODE:
after uploading the code you need to scan the ir-remote like open serial monitor and then click the buttons on the remote then you will see the button unique number 

#include <IRremote.h>

int IRpin = 12;
IRrecv irrecv(IRpin);
decode_results results;


void setup()
{
  Serial.begin(9600);
  irrecv.enableIRIn();
}  
void loop() 
{   
  if (irrecv.decode(&results)) 
    {
     Serial.println(results.value); // Print the Serial 'results.value'
      delay(10);

     irrecv.resume();// Receive the next value
    }
   

B. HOME AUTOMATION CODE

#include <IRremote.h>

int IRpin = 12;
IRrecv irrecv(IRpin);
decode_results results;
 
void setup()
{
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver

  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(7, OUTPUT);
}  
void loop() {   
  if (irrecv.decode(&results)) 
    {
     Serial.println(results.value); // Print the Serial 'results.value'
      delay(10);

     irrecv.resume();   // Receive the next value
    }


if(results.value == 584701991){
  digitalWrite(4, HIGH);
}
if(results.value == 584687711){
  digitalWrite(4, LOW);
}


if(results.value == 584708111){
  digitalWrite(5, HIGH);
}
if(results.value == 584655071){
  digitalWrite(5, LOW);
}


if(results.value == 584695871){
  digitalWrite(6, HIGH);
}
if(results.value == 584663231){
  digitalWrite(6, LOW);
}


if(results.value == 584685671){
  digitalWrite(7, HIGH);
}
if(results.value == 584677511){
  digitalWrite(7, LOW);
}


if(results.value == 584699951){
  digitalWrite(4, LOW);
  digitalWrite(5, LOW);
  digitalWrite(6, LOW);
  digitalWrite(7, LOW);
}
   

Post a Comment

0 Comments