ReceiveDemo_Simple.ino 607 B

1234567891011121314151617181920212223242526272829
  1. /*
  2. Simple example for receiving
  3. https://github.com/sui77/rc-switch/
  4. */
  5. #include <RCSwitch.h>
  6. RCSwitch mySwitch = RCSwitch();
  7. void setup() {
  8. Serial.begin(9600);
  9. mySwitch.enableReceive(0); // Receiver on interrupt 0 => that is pin #2
  10. }
  11. void loop() {
  12. if (mySwitch.available()) {
  13. Serial.print("Received ");
  14. Serial.print( mySwitch.getReceivedValue() );
  15. Serial.print(" / ");
  16. Serial.print( mySwitch.getReceivedBitlength() );
  17. Serial.print("bit ");
  18. Serial.print("Protocol: ");
  19. Serial.println( mySwitch.getReceivedProtocol() );
  20. mySwitch.resetAvailable();
  21. }
  22. }