phillip_bourdon234

TaserBot_REMOTE

Mar 14th, 2020 (edited)
665
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.73 KB | None | 0 0
  1. // A video demonstration of this project can be found here: https://bit.ly/3fuLpY6
  2.  
  3. #include <nRF24L01.h>
  4. #include <printf.h>
  5. #include <RF24.h>
  6. #include <RF24_config.h>
  7. #include <SPI.h>
  8.  
  9. #define X_JOY A4
  10. #define Y_JOY A3
  11.  
  12. RF24 radio(7,8); // ce, cs
  13. const byte address[6] = "111111";
  14.  
  15. int button = 4;
  16. int States[3];
  17.  
  18. void setup()
  19. {
  20.   radio.begin();
  21.   radio.openWritingPipe(address);
  22.   radio.setPALevel(RF24_PA_HIGH);
  23.   pinMode(X_JOY, INPUT);
  24.   pinMode(Y_JOY, INPUT);
  25.   pinMode(button, INPUT_PULLUP);
  26. }
  27.  
  28. void loop()
  29. {
  30.   delay(5);  
  31.  
  32.   radio.stopListening();
  33.  
  34.   States[0] = analogRead(X_JOY);
  35.   States[1] = analogRead(Y_JOY);
  36.   States[2] = digitalRead(button);
  37.  
  38.   radio.write(&States, sizeof(States));
  39. }
Add Comment
Please, Sign In to add comment