SHARE
TWEET

Untitled

a guest Oct 14th, 2019 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <SPI.h>
  2. #include <nRF24L01.h>
  3. #include <RF24.h>
  4.  
  5. #define jB1 0
  6.  
  7. RF24 radio(9, 10);
  8.  
  9. const byte address[6] = "00001"; // Address
  10.  
  11. struct Data_Package {
  12.   byte j1PotX;
  13.   byte j1PotY;
  14. //  byte j1Button;
  15. };
  16.  
  17. Data_Package data;
  18.  
  19. void setup() {
  20.   Serial.begin(9600);
  21.  
  22.   radio.begin();
  23.   radio.openWritingPipe(address);
  24.   radio.setAutoAck(false);
  25.   radio.setDataRate(RF24_250KBPS);
  26.   radio.setPALevel(RF24_PA_LOW);
  27.  
  28.   pinMode(jB1, INPUT_PULLUP);
  29. //  pinMode(t1, INPUT_PULLUP);
  30.  
  31.   data.j1PotX = 90;
  32.   data.j1PotY = 90;
  33. //  data.j1Button = 1;
  34. }
  35.  
  36. void loop() {
  37.   data.j1PotX = map(analogRead(A0), 0, 1023, 0, 180);
  38.   data.j1PotY = map(analogRead(A1), 0, 1023, 0, 180);
  39. //  data.j1Button = digitalRead(jB1);
  40.  
  41.   radio.write(&data, sizeof(Data_Package));
  42.   Serial.println(data.j1PotX);
  43.   Serial.println(data.j1PotY);
  44. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top