SWITCH BY IR REMOTE

IR LED

 

#include <IRremote.h>

int RECV_PIN = 5;

int OUTPUT_PIN = 9;

IRrecv irrecv(RECV_PIN);

decode_results results;

void setup()

{

pinMode(OUTPUT_PIN, OUTPUT);

pinMode(9, OUTPUT);

irrecv.enableIRIn(); // Start the receiver

}

int on = 0;

unsigned long last = millis();

void loop() {

if (irrecv.decode(&results)) {

// If it’s been at least 1/4 second since the last

// IR received, toggle the relay

if (millis() – last > 250) {

on = !on;

digitalWrite(OUTPUT_PIN, on ? HIGH : LOW);

}

last = millis();

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

}

}

OTHER SKET

#include <IRremote.h>

int RECV_PIN = 3;

int OUTPUT_PIN = 4;

IRrecv irrecv(RECV_PIN);

decode_results results;

void setup()

{

pinMode(OUTPUT_PIN, OUTPUT);

pinMode(13, OUTPUT);

irrecv.enableIRIn(); // Start the receiver

}

int on = 0;

unsigned long last = millis();

void loop() {

if (irrecv.decode(&results)) {

if (results.value == 0xEF1001FE) {

digitalWrite(OUTPUT_PIN, HIGH);

}

else if (results.value == 0xEF1055AA) {

digitalWrite(OUTPUT_PIN, LOW);

}

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

}

}

OTHER SKET

#include <IRremote.h>

int RECV_PIN = 3;

int OUTPUT_PIN = 4;

IRrecv irrecv(RECV_PIN);

decode_results results;

void setup()

{

pinMode(OUTPUT_PIN, OUTPUT);

pinMode(13, OUTPUT);

irrecv.enableIRIn(); // Start the receiver

}

int on = 0;

unsigned long last = millis();

void loop() {

if (irrecv.decode(&results)) {

if (results.value == 0xEF1001FE) { // TIVO button

// If it’s been at least 1/4 second since the last

// IR received, toggle the relay

if (millis() – last > 250) {

on = !on;

digitalWrite(OUTPUT_PIN, on ? HIGH : LOW);

}

last = millis();

}

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

}

}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s