Skip to main content

IR Switch (Arduino)

IR SWITCH

This project is used to control leds or relays using ir remote.
FOR VIDEO :

THINGS NEEDED

  1. Arduino NANO
  2. IR Receiver KY-022 Module
  3. Leds

CIRCUIT DIAGRAM

IR DECODE

IR SWITCH


WIRING

IR DECODE

IR RECEIVER MODULE TO ARDUINO

  • Connect the VCC of IR Receiver to VCC Rail.
  • Connect the GND of IR Receiver to GND Rail.
  • Connect the S (Singnal) pin to pin D2 of arduino nano.

IR SWITCH

IR RECEIVER MODULE TO ARDUINO

  • Connect the VCC of IR Receiver to VCC Rail.
  • Connect the GND of IR Receiver to GND Rail.
  • Connect the S (Singnal) pin to pin D2 of arduino nano.

LED TO ARDUINO

  • Connect LED1 to pin 12 of Arduino.
  • Connect LED2 to pin 11 of Arduino.
  • Connect LED3 to pin 10 of Arduino.
  • Connect LED4 to pin  9  of Arduino.

LIBRARY NEEDED

IR REMOTE LIBRARY : 

CODE

IR DECODE :  | IR SWITCH : 

IR DECODE

//IR Decode 
//scientist BENIELS LAB 
#include <IRremote.h>

int RECV_PIN = 2;
IRrecv irrecv(RECV_PIN);
decode_results results;


void setup()
{
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
}

void loop()
{
  if (irrecv.decode(&results))
    {
     Serial.println(results.value);
     irrecv.resume(); // Receive the next value
    }
}

IR SWITCH

//IR Switch 
//scientist BENIELS LAB 

#include <IRremote.h>
int state1;
int state2;
int state3;
int state4;
int state5;


int RECV_PIN = 2;
int ch1 = 12;
int ch2 = 11;
int ch3 = 10;
int ch4 = 9;
int ch5 = 8;

IRrecv irrecv(RECV_PIN);

decode_results results;

void setup()
{
  Serial.begin(9600);
  // In case the interrupt driver crashes on setup, give a clue
  // to the user what's going on.
  Serial.println("Enabling IRin");
  irrecv.enableIRIn(); // Start the receiver
  Serial.println("Enabled IRin");
  pinMode (ch1, OUTPUT);
  pinMode (ch2, OUTPUT);
  pinMode (ch3, OUTPUT);
  pinMode (ch4, OUTPUT);
  pinMode (ch5, OUTPUT);
    }

void loop() {


  if (irrecv.decode(&results)) {
  //CH1
    if (results.value==16753245)
    {
      if (state1==0){
        digitalWrite(ch1,HIGH);
        state1=1;

      }
      else{
        digitalWrite(ch1,LOW);
        state1=0;

        delay(100);
     
      }}
      //CH2
      if (results.value==16736925){
      if (state2==0){
        digitalWrite(ch2,HIGH);
        state2=1;     

      }
      else{
        digitalWrite(ch2,LOW);
        state2=0;
delay(100);
      }}
      //CH3
       if (results.value==16769565){
      if (state3==0){
        digitalWrite(ch3,HIGH);
        state3=1;

      }
      else{
        digitalWrite(ch3,LOW);
        state3=0;
delay(100);
      }}
      //CH4
       if (results.value==16720605){
      if (state4==0){
        digitalWrite(ch4,HIGH);
        state4=1;
   
      }
      else{
        digitalWrite(ch4,LOW);
        state4=0;
     delay(100);
      }}
    
    //CH5
    if (results.value==16712445){
      if (state5==0){
        digitalWrite(ch5,HIGH);
        state5=1;
      }
      else{
        digitalWrite(ch5,LOW);
        state5=0;
       delay(100);         
      }}    


irrecv.resume(); // Receive the next value
  }
  delay(100);
}//loop end
SUBSCRIBE TO "scientist BENIEL'S LAB" IN YOUTUBE FOR MORE ELECTRONIC'S & ROBOTIC'S PROJECTS.
THANK YOU

Comments

Popular posts from this blog

Arduno Clock

  Arduino Clock This is a clock using RTC Tiny with Arduino. Using this we can see time & date.  FOR VIDEO :

MQ-5 GAS LEAK DETECTOR

  MQ-5 GAS LEAK DETECTOR  This project is used to detect the gas leak and alert us that the gas is leaking. You can use it for your science projects. FOR VIDEO :

Blutooth Switch (Arduino)

 BLUTOOTH SWITCH (ARDUINO) Hi, Using this we can control leds using Smart Phone via Blutooth. We can also control home appliances using Relay with it. For Video :  CLICK HERE  .