Papermind

rfm

Dec 31st, 2017
702
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.91 KB | None | 0 0
  1. /* receiver.pde
  2. Author: Mike McCauley ([email protected])
  3. Copyright (C) 2008 Mike McCauley
  4. Modified By Muhammad Hasan
  5. */
  6. #include <VirtualWire.h>
  7. const int led_pin = 13;
  8. const int receive_pin = 12;
  9. void setup()
  10. {
  11. delay(1000);
  12. Serial.begin(9600); // Debugging only
  13. Serial.println("setup");
  14. vw_set_rx_pin(receive_pin);
  15. vw_set_ptt_inverted(true); // Required for DR3100
  16. vw_setup(2000); // Bits per sec
  17. vw_rx_start(); // Start the receiver PLL running
  18. pinMode(led_pin, OUTPUT);
  19. }
  20. void loop()
  21. {
  22. uint8_t buf[VW_MAX_MESSAGE_LEN];
  23. uint8_t buflen = VW_MAX_MESSAGE_LEN;
  24. if (vw_get_message(buf, &buflen)) // Non-blocking
  25. {
  26. int i;
  27. digitalWrite(led_pin, HIGH); // Flash a light to show
  28. received good message
  29. // Message with a good checksum received, dump it.
  30. Serial.print("Got: ");
  31. for (i = 0; i < buflen; i++)
  32. {
  33. Serial.print(buf[i]);
  34. Serial.print(' ');
  35. }
  36. Serial.println();
  37. digitalWrite(led_pin, LOW);
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment