Vishesh Varma
Published © GPL3+

Infrared Controlled Appliances

Using a infrared sensor and a Infrared remote, controlling conventional appliances.

IntermediateProtip59
Infrared Controlled Appliances

Things used in this project

Story

Read more

Schematics

CIRCUIT DIAGRAM FOR THE PROJECT.png

Code

Remote Controlling appliances Code

Arduino
Copy and paste this code and connect the actuators according to the code
#include<IRremote.h>

const int recv_pin=7;
IRrecv irrecv(recv_pin);
decode_results result;
const int relay_1=10;
const int relay_2=11;
int i=1,j=1;

void setup() {
 irrecv.enableIRIn();
 irrecv.blink13(true);
 Serial.begin(9600);
 pinMode(relay_1,OUTPUT);
 pinMode(relay_2,OUTPUT);// put your setup code here, to run once:

}

void loop() {
 if(irrecv.decode(&result))
  {
    switch(result.value)
    {
      case 0x1FEE01F: //Case when 0 is pressed
        if(i>=0)
          digitalWrite(relay_1, HIGH);
        else
          digitalWrite(relay_1,LOW);
          i*=-1;
        break;
      case 0x1FE50AF: //Case when 1 is pressed
        if(j>=0)
          digitalWrite(relay_2, HIGH);
        else
          digitalWrite(relay_2,LOW);
          j*=-1;
        break;
      case 0xFFFFFFF: //Case when Long press is detected
        Serial.println("Long press detected");
        break;
      default:
        Serial.println("Wrong input/Random Input. Press 0 or 1 on the remote");
    }
    irrecv.resume();
  }

}

Credits

Vishesh Varma

Vishesh Varma

0 projects • 0 followers

Comments