SHARE
TWEET

RCSwitch.SimpleReceive

a guest Mar 27th, 2014 29 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.   Simple example for receiving
  3.  
  4.   http://code.google.com/p/rc-switch/
  5.  
  6.   Need help? http://forum.ardumote.com
  7. */
  8.  
  9. #include <RCSwitch.h>
  10.  
  11. RCSwitch mySwitch = RCSwitch();
  12.  
  13. void setup() {
  14.   Serial.begin(9600);
  15.   mySwitch.enableReceive(0);  // Receiver on inerrupt 0 => that is pin #2
  16. }
  17.  
  18. void loop() {
  19.   if (mySwitch.available()) {
  20.    
  21.     int value = mySwitch.getReceivedValue();
  22.    
  23.     if (value == 0) {
  24.       Serial.print("Unknown encoding");
  25.     } else {
  26.       Serial.print("Received ");
  27.       Serial.print( mySwitch.getReceivedValue() );
  28.       Serial.print(" / ");
  29.       Serial.print( mySwitch.getReceivedBitlength() );
  30.       Serial.print("bit ");
  31.       Serial.print("Protocol: ");
  32.       Serial.println( mySwitch.getReceivedProtocol() );
  33.       Serial.print("Received RAW Data: ");
  34.       Serial.println((int) mySwitch.getReceivedRawdata());
  35.     }
  36.  
  37.     mySwitch.resetAvailable();
  38.   }
  39. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top