Skip to content

Instantly share code, notes, and snippets.

@embed0
Created March 18, 2016 11:21
Show Gist options
  • Save embed0/a5f501193dc9d108f51e to your computer and use it in GitHub Desktop.
Save embed0/a5f501193dc9d108f51e to your computer and use it in GitHub Desktop.
arduino reciver relay code
/*
RF_Sniffer
Hacked from http://code.google.com/p/rc-switch/
by @justy to provide a handy RF code sniffer
*/
#include "RCSwitch.h"
#include <stdlib.h>
#include <stdio.h>
RCSwitch mySwitch = RCSwitch();
int msg;
int relayPin = 5;
void setup() {
Serial.begin(9600);
mySwitch.enableReceive(0); // Receiver on inerrupt 0 =&gt; that is pin #2
}
void loop() {
if (mySwitch.available())
{
int value = mySwitch.getReceivedValue();
if (value == 0) {
Serial.print("Unknown encoding");
}
else
{
msg = mySwitch.getReceivedValue();
Serial.println( msg );
if( msg == 1111)
{
digitalWrite(relayPin, LOW);
}
if( msg == 1000)
{
digitalWrite(relayPin, HIGH);
}
msg = 0;
}
mySwitch.resetAvailable();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment