Uploaded from my local repository
[433Utils_NP] / rc-switch / examples / ReceiveDemo_Simple / ReceiveDemo_Simple.pde
1 /*
2   Simple example for receiving
3   
4   https://github.com/sui77/rc-switch/
5 */
6
7 #include <RCSwitch.h>
8
9 RCSwitch mySwitch = RCSwitch();
10
11 void setup() {
12   Serial.begin(9600);
13   mySwitch.enableReceive(0);  // Receiver on interrupt 0 => that is pin #2
14 }
15
16 void 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 }
Contact me: dev (at) shalnoff (dot) com
PGP fingerprint: A6B8 3B23 6013 F18A 0C71 198B 83D8 C64D 917A 5717