Guest User

Untitled

a guest
Feb 12th, 2018
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. #include <VirtualWire.h>
  2.  
  3. const int receive_pin = 11;
  4.  
  5. void setup()
  6. {
  7. delay(1000);
  8. Serial.begin(9600); // Debugging only
  9. Serial.println("setup");
  10.  
  11. // Initialise the IO and ISR
  12.  
  13. vw_set_rx_pin(receive_pin);
  14.  
  15. vw_setup(2000); // Bits per sec
  16.  
  17. vw_rx_start(); // Start the receiver PLL running
  18. }
  19.  
  20. void loop()
  21. {
  22. uint8_t buf[VW_MAX_MESSAGE_LEN];
  23. uint8_t buflen = VW_MAX_MESSAGE_LEN;
  24.  
  25. if (vw_get_message(buf, &buflen))
  26. {
  27.  
  28. int i;
  29.  
  30.  
  31. Serial.print("Got: ");
  32.  
  33. for (i = 0; i < buflen; i++)
  34. {
  35. Serial.print(char(buf[i]));
  36.  
  37. }
  38. Serial.println();
  39.  
  40. }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment