Created
May 21, 2018 17:14
-
-
Save thibmaek/d64c4686c49b086e905353d47e0dc2c6 to your computer and use it in GitHub Desktop.
RF Simple receive (Arduino)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Simple example for receiving | |
https://github.com/sui77/rc-switch/ | |
*/ | |
#include <RCSwitch.h> | |
RCSwitch mySwitch = RCSwitch(); | |
void setup() { | |
Serial.begin(9600); | |
mySwitch.enableReceive(0); // Receiver on interrupt 0 => that is pin #2 | |
} | |
void loop() { | |
if (mySwitch.available()) { | |
int value = mySwitch.getReceivedValue(); | |
if (value == 0) { | |
Serial.print("Unknown encoding"); | |
} else { | |
Serial.print("Received "); | |
Serial.print( mySwitch.getReceivedValue() ); | |
Serial.print(" / "); | |
Serial.print( mySwitch.getReceivedBitlength() ); | |
Serial.print("bit "); | |
Serial.print("Protocol: "); | |
Serial.println( mySwitch.getReceivedProtocol() ); | |
} | |
mySwitch.resetAvailable(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment