/*
Simple example for receiving
https://github.com/sui77/rc-switch/
*/
#include <RCSwitch.h>
#define relay (13)
RCSwitch mySwitch = RCSwitch();
unsigned long num ;
void setup() {
Serial.begin(9600);
mySwitch.enableReceive(0); // Receiver on interrupt 0 => that is pin #2
pinMode(relay, OUTPUT);
digitalWrite(relay, HIGH);
}
void loop() {
if (mySwitch.available()) {
Serial.print("Received ");
Serial.print( mySwitch.getReceivedValue() );
Serial.print(" / ");
num=mySwitch.getReceivedValue();
if(num==15307640){digitalWrite(relay, LOW);} //thay đổi số 15307640 tương ứng
if(num==15307636){digitalWrite(relay, HIGH);}//thay đổi số 15307636 tương ứng
mySwitch.resetAvailable();
}
}
|