Advertisement
computermuseo

lettura arduino 433/315 simple

Mar 26th, 2017
3,153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. #include <RCSwitch.h>
  2.  
  3. RCSwitch mySwitch = RCSwitch();
  4.  
  5. void setup() {
  6. Serial.begin(9600);
  7. mySwitch.enableReceive(0); // Receiver on interrupt 0 => that is pin #2
  8. }
  9.  
  10. void loop() {
  11. if (mySwitch.available()) {
  12.  
  13. int value = mySwitch.getReceivedValue();
  14.  
  15. if (value == 0) {
  16. Serial.print("Unknown encoding");
  17. } else {
  18. Serial.print("Received ");
  19. Serial.print( mySwitch.getReceivedValue() );
  20. Serial.print(" / ");
  21. Serial.print( mySwitch.getReceivedBitlength() );
  22. Serial.print("bit ");
  23. Serial.print("Protocol: ");
  24. Serial.println( mySwitch.getReceivedProtocol() );
  25. }
  26.  
  27. mySwitch.resetAvailable();
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement