Advertisement
Guest User

RX-NRF

a guest
Oct 21st, 2014
295
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. #include <nRF24L01.h>
  2. #include <RF24.h>
  3. #include <RF24_config.h>
  4. #include <SPI.h>
  5.  
  6. #define PPM 2
  7.  
  8. const uint64_t pipe = 0xE8E8F0F0E1LL;
  9. RF24 radio(9,10);
  10. int joystick[1];
  11.  
  12. void setup()
  13. {
  14. pinMode(PPM, OUTPUT);
  15.  
  16. radio.begin();
  17.  
  18. radio.setPALevel(RF24_PA_MAX);
  19. radio.setPayloadSize(10);
  20. radio.setDataRate(RF24_250KBPS);
  21. radio.setRetries(15,15);
  22.  
  23. radio.openReadingPipe(1,pipe);
  24. radio.startListening();;
  25. }
  26.  
  27. void loop()
  28. {
  29. if(radio.available())
  30. {
  31.  
  32. bool done=false;
  33. while(!done)
  34. {
  35. done=radio.read(joystick,sizeof(joystick));
  36. }
  37.  
  38. int x = joystick[0];
  39.  
  40. digitalWrite(PPM, x);
  41.  
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement