Project showcase
Arduino: Switching ON/OFF Appliances Using IR Remote

Arduino: Switching ON/OFF Appliances Using IR Remote © GPL3+

Press 'Power' to switch everything ON/OFF. Press '1' for the fan and '2' for the lights.

  • 12,700 views
  • 0 comments
  • 128 respects

Components and supplies

Apps and online services

About this project

Use an IR Remote to control the appliances (fan and light here).

Instructions :

  • Press the red power button to switch OFF/ON both things at once.
  • Press button 1 to switch ON the fan and press 2 to switch ON the light.
  • Press button 1 again to switch off the fan and so for the light, too.

If you are making this project in real life, remember to power the relay SPDT with 5V coil through a 5V source only, and for the best performance of appliances, allow an external high power supply in the COM terminal of the relay.

But make sure that the high voltage wires should not come in contact with the low voltage Arduino and LCD circuitry as they work on 5V and short circuiting in the the system may damage the Arduino and other components.

Note : With different IR remotes, you should first check the codes of each button of the remote you are using.

And, please respect the project so that I can get Rep points for shopping some another components.

Code

Arduino | Switching ON/OFF appliances using IR RemoteC/C++
#include <IRremote.h>      //including infrared remote header file
#include <LiquidCrystal.h>    //including LCD header file

#define code1  16582903   // code received from button 1
#define code2  16615543   // code received from button 2
#define code3  16580863   // code received from "power button"

LiquidCrystal lcd(12,10,7,6,5,4);

int RECV_PIN = 11;        // the pin where you connect the output pin of IR sensor 
IRrecv irrecv(RECV_PIN);
decode_results results;

int app1 = 3;         //fan pin
int app2 = 2;         //bulb pin
int status[] = {0,0,0,0};
/* the initial state of appliances is OFF (zero) 
the first zero must remain zero but you can 
change the others to 1's if you want a certain
appliance to be ON when the board is powered */
 
void setup()
{
  Serial.begin(9600);
  lcd.begin(16,2);          // Start the LCD
  irrecv.enableIRIn();        // Start the IR receiver
  
  pinMode(app1, OUTPUT);
  pinMode(app2, OUTPUT);
  
  lcd.setCursor(0,0);     
  lcd.print("Made by Naman");   // Made by Naman Chauhan
  lcd.setCursor(0,1);
  lcd.print("Chauhan");
  delay(1500);
  lcd.clear();
  
  lcd.setCursor(3,0);
  lcd.print("Arduino IR");      //Arduino IR Switch Board
  lcd.setCursor(2,1);
  lcd.print("Switch Board");
  delay(1500);
  lcd.clear();
  
  lcd.setCursor(0,0);
  lcd.print("(1) Fan : OFF");     //Showing intial status on LCD
  lcd.setCursor(0,1);
  lcd.print("(2) Bulb : OFF");
  
}
 
void loop() 
{
  if (irrecv.decode(&results)) {
    unsigned int value = results.value;
    switch(value) {
      
       case code1:
         if(status[1] == 1) {           // if first app is ON then
            digitalWrite(app1, LOW);      // turn it off when button is pressed
            status[1] = 0;              // and set its state as off
            lcd.setCursor(10,0);      //printing status on LCD
            lcd.print("OFF");
          }
      
        else {                          // else if first app is OFF then
              digitalWrite(app1, HIGH);   // turn it on when the button is pressed
              status[1] = 1;            // and set its state as ON
              lcd.setCursor(10,0);    //printing status on LCD
              lcd.print("ON ");
           }
              break;
      
      
       case code2:
         if(status[2] == 1) {
            digitalWrite(app2, LOW);
            status[2] = 0;
            lcd.setCursor(11,1);      //printing status on LCD
            lcd.print("OFF");
         } 
      
        else {
              digitalWrite(app2, HIGH);
              status[2] = 1;
              lcd.setCursor(11,1);      //printing status on LCD
              lcd.print("ON ");
           }
              break;
              
       case code3:
         if(status[1] == 1 && status[2] == 1) {
            digitalWrite(app1, LOW);      
            status[1] = 0;              
            lcd.setCursor(10,0);      
            lcd.print("OFF");

            digitalWrite(app2, LOW);
            status[2] = 0;
            lcd.setCursor(11,1);      
            lcd.print("OFF");
           }

         else {
               digitalWrite(app1, HIGH);   
               status[1] = 1;            
               lcd.setCursor(10,0);    
               lcd.print("ON ");

               digitalWrite(app2, HIGH);
               status[2] = 1;
               lcd.setCursor(11,1);      
               lcd.print("ON ");
         }
      
    }
    Serial.println(value);      
    irrecv.resume();       // Receive the next value
  }
}

Schematics

Circuit Diagram
Capture nxoqql5pq9
Schematics
Schematics twetdz5nzp
Autodesk 123 Circuits Schematics
https://circuits.io/circuits/5252611-arduino-switching-on-off-appliances-using-ir-remote/edit#breadboard

https://circuits.io/circuits/5252611-arduino-switching-on-off-appliances-using-ir-remote/edit#breadboard

Comments

Similar projects you might like

IR Remote Controlled Power Switch for Rapsberry Pi 3

Project tutorial by Vilém Kužel

  • 1,084 views
  • 1 comment
  • 5 respects

Servo Control with TV Remote Control

Project showcase by eldo85

  • 5,604 views
  • 5 comments
  • 17 respects

Developing an IR Remote and Software Controller

Project tutorial by Steve

  • 18,069 views
  • 0 comments
  • 35 respects

Play Music With Your Remote

Project tutorial by Simone Adobs

  • 7,848 views
  • 21 comments
  • 29 respects
Add projectSign up / Login