Advertisement
tommasta

Spektrum AR600 Receiver Code for Arduino

Apr 14th, 2012
522
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.31 KB | None | 0 0
  1. //This code allows the receiving of inputs from the Spektrum AR600
  2. //Radio Receiver.  It is written to test the onboard inputs on the
  3. //Rainbowduino (which do not function properly when Rb.init() is
  4. //called, due to the inputs being used for driving the display).
  5. //The code is easily adaptable for Arduino and any other
  6. //microcontroller you want to add remote capabilities to.  The AR600
  7. //provides input values ranging from approximately 1000 to 2000.
  8.  
  9. int rx1 = 0;  //throttle control
  10. int rx2 = 0;  //aileron control
  11. int rx3 = 0;  //elevation control
  12. int rx4 = 0;  //rudder control
  13. int rx5 = 0;  //AUX switch
  14. int rx6 = 0;  //Trainer momentary switch
  15. #include <Arduino.h>
  16. unsigned long time1 = 0;
  17. unsigned long time2 = 0;
  18. void setup() {
  19.   Rb.init();                 // initialize
  20.   Serial.begin(115200);      // open the serial port at 115200 bps:
  21. }
  22.  
  23. void loop() {
  24.   rx1=pulseIn(A0,HIGH);
  25.   rx2=pulseIn(A1,HIGH);
  26.   rx3=pulseIn(A2,HIGH);
  27.   rx4=pulseIn(A3,HIGH);
  28.   rx5=pulseIn(2,HIGH);
  29.   rx6=pulseIn(3,HIGH);
  30.   Serial.print(rx1);
  31.   Serial.print("\t");
  32.   Serial.print(rx2);
  33.   Serial.print("\t");
  34.   Serial.print(rx3);
  35.   Serial.print("\t");
  36.   Serial.print(rx4);
  37.   Serial.print("\t");
  38.   Serial.print(rx5);
  39.   Serial.print("\t");
  40.   Serial.print(rx6);
  41.   Serial.print("\t");
  42.   Serial.println("\t");
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement