phillip_bourdon234

ShotDeliverSystem_Remote

Jun 10th, 2020 (edited)
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.92 KB | None | 0 0
  1. // A demonstration of this project can be found here: https://bit.ly/2Ynx09x
  2.  
  3. /*
  4.     Parts used for the remote:
  5.     [1] joystick module
  6.     [1] standard push button
  7.     [1] Arduino Nano
  8.     [1] 9v battery
  9.     [1] power switch
  10.     [1] NRF24L01 module
  11.     [20+] jumper wires
  12. */
  13.  
  14. #include <nRF24L01.h>
  15. #include <printf.h>
  16. #include <RF24.h>
  17. #include <RF24_config.h>
  18. #include <SPI.h>
  19.  
  20. #define X_JOY A4
  21. #define Y_JOY A3
  22.  
  23. RF24 radio(7,8); // ce, cs
  24. const byte address[6] = "111111";
  25.  
  26. int button = 4;
  27. int States[3];
  28.  
  29. void setup()
  30. {
  31.   radio.begin();
  32.   radio.openWritingPipe(address);
  33.   radio.setPALevel(RF24_PA_HIGH);
  34.   pinMode(X_JOY, INPUT);
  35.   pinMode(Y_JOY, INPUT);
  36.   pinMode(button, INPUT_PULLUP);
  37. }
  38.  
  39. void loop()
  40. {
  41.   delay(5);  
  42.  
  43.   radio.stopListening();
  44.  
  45.   States[0] = analogRead(X_JOY);
  46.   States[1] = analogRead(Y_JOY);
  47.   States[2] = digitalRead(button);
  48.  
  49.   radio.write(&States, sizeof(States));
  50. }
Add Comment
Please, Sign In to add comment