Advertisement
Guest User

CCCRECEIVE

a guest
Jul 19th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. // Include RadioHead Amplitude Shift Keying Library
  2. #include <RH_ASK.h>
  3. // Include dependant SPI Library
  4. #include <SPI.h>
  5.  
  6. // Create Amplitude Shift Keying Object
  7. RH_ASK rf_driver;
  8. int i;
  9.  
  10. void setup()
  11. {
  12. // Initialize ASK Object
  13. rf_driver.init();
  14. // Setup Serial Monitor
  15. Serial.begin(9600);
  16. pinMode(13,OUTPUT);
  17. }
  18.  
  19. void loop()
  20. {
  21. // Set buffer to size of expected message
  22. uint8_t buf[1];
  23. uint8_t buflen = sizeof(buf);
  24. // Check if received packet is correct size
  25. if (rf_driver.recv(buf, &buflen))
  26. {
  27.  
  28. // Message received with valid checksum
  29. //Serial.print("Message Received: ");
  30. Serial.println((char*)buf);
  31. i= atoi((char*)buf);
  32. if (i==1){digitalWrite(13,HIGH);}
  33. else if (i==0){digitalWrite(13,LOW);}
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement