libraries / rc-switch-2.52 / examples / ReceiveDemo_Simple / ReceiveDemo_Simple.pdeon commit Added link to project report (97a3ba0)
   1/*
   2  Simple example for receiving
   3  
   4  http://code.google.com/p/rc-switch/
   5*/
   6
   7#include <RCSwitch.h>
   8
   9RCSwitch mySwitch = RCSwitch();
  10
  11void setup() {
  12  Serial.begin(9600);
  13  mySwitch.enableReceive(0);  // Receiver on inerrupt 0 => that is pin #2
  14}
  15
  16void loop() {
  17  if (mySwitch.available()) {
  18    
  19    int value = mySwitch.getReceivedValue();
  20    
  21    if (value == 0) {
  22      Serial.print("Unknown encoding");
  23    } else {
  24      Serial.print("Received ");
  25      Serial.print( mySwitch.getReceivedValue() );
  26      Serial.print(" / ");
  27      Serial.print( mySwitch.getReceivedBitlength() );
  28      Serial.print("bit ");
  29      Serial.print("Protocol: ");
  30      Serial.println( mySwitch.getReceivedProtocol() );
  31    }
  32
  33    mySwitch.resetAvailable();
  34  }
  35}