Muhammad_Munir
Published © GPL3+

Switch ON Bulb with TV remote

Control your home appliances with TV remote.

BeginnerFull instructions provided64
Switch ON Bulb with TV remote

Things used in this project

Story

Read more

Code

Control bulb with IR

Arduino
#include <IRremote.h>


//Relay PIN
#define relePIN 12

//IR sensor PIN
int RECV_PIN = 3;

//Control LED PIN
int LED_PIN = 10;

IRrecv irrecv(RECV_PIN);
decode_results results;

void setup()
{
  pinMode(relePIN, OUTPUT);
  pinMode(LED_PIN, OUTPUT);
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
}

void loop()
{
  if (irrecv.decode(&results))
  {
    Serial.print(results.value, HEX);
    Serial.print(" - ");
    Serial.println(results.value);
    if (results.value == 4294967295){
      digitalWrite(relePIN, HIGH); // Relay ON
      digitalWrite(LED_PIN, HIGH); // LED ON
    } 
    if (results.value == 16769565){
      digitalWrite(relePIN, LOW); // Relay OFF
      digitalWrite(LED_PIN, LOW); // LED OFF
    } 
    irrecv.resume(); // Receive the next value
  }
}

Credits

Muhammad_Munir

Muhammad_Munir

1 project • 2 followers

Comments