Advertisement
Guest User

Untitled

a guest
Nov 28th, 2014
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.06 KB | None | 0 0
  1. #include <SPI.h>
  2. #include <nRF24L01.h>
  3. #include <RF24.h>
  4.  
  5. #define CE_PIN   9
  6. #define CSN_PIN 10
  7. #define ROLL A0
  8. #define PITCH A1
  9. #define YAW A2
  10. #define THROTTLE A3
  11. #define MODE 2
  12. #define AUX1 3
  13. #define AUX2 4
  14. #define AUX3 5
  15.  
  16. const uint64_t pipe = 0xE8E8F0F0E1LL;
  17.  
  18. RF24 radio(CE_PIN, CSN_PIN);
  19.  
  20. int joystick[8];
  21.  
  22. void setup()
  23. {
  24.   Serial.begin(9600);
  25.   radio.begin();
  26.   radio.openWritingPipe(pipe);
  27.   pinMode(2, INPUT);
  28.   pinMode(3, INPUT);
  29.   pinMode(4, INPUT);
  30.   pinMode(5, INPUT);
  31.  
  32. }
  33.  
  34.  
  35. void loop()
  36. {
  37.   joystick[0] = analogRead(ROLL);
  38.   joystick[1] = analogRead(PITCH);
  39.   joystick[2] = analogRead(YAW);
  40.   joystick[3] = analogRead(THROTTLE);
  41.   joystick[4] = digitalRead(MODE);
  42.   joystick[5] = digitalRead(AUX1);
  43.   joystick[6] = digitalRead(AUX2);
  44.   joystick[7] = digitalRead(AUX3);
  45.  
  46.   radio.write( joystick, sizeof(joystick) );
  47.  
  48.   //debug
  49.   Serial.print(joystick[0]);
  50.   Serial.print("  ");
  51.   Serial.print(joystick[1]);
  52.   Serial.print("  ");
  53.   Serial.print(joystick[2]);
  54.   Serial.print("  ");
  55.    Serial.println(joystick[3]);
  56.  
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement