rc_receiver_driving.ino 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. //#define SCAN_MODE // If set, scan & output channel values, rather than driving the robot.
  2. /////////////////////////////////////////////////////////////////////////
  3. // Configuration
  4. //////////////////////////////////////////////////
  5. #define MAX_POWER_PERCENT 90 // The maximum percentage on time, used to decrease average voltage to the motor.
  6. #define OUTPUT_RANGE 255 // The maximum value for PWM output
  7. ///////////////////////
  8. #define SCAN_DELAY 10 // Delay between updates in ms
  9. #define AVG_PERIODS 10 // Number of periods to average the speed over (reduces random variances)
  10. /////////////////////////////////////////////////////////////////////////
  11. // Channel pins
  12. /////////////////////////////////////////////////////////////////////////
  13. #define LOW_CHANNEL 1
  14. #define NUM_CHANNELS 6
  15. // Channel pins. Using numbers 1-6 for clarity, so using a bad value in index 0.
  16. const byte channels[7] = {255, 8,9,10,11,12,13};
  17. // How long (in microseconds) the channel is being held high for.
  18. int channelVals[NUM_CHANNELS + 1];
  19. /////////////////////////////////////////////////////////////////////////
  20. // Channel values
  21. /////////////////////////////////////////////////////////////////////////
  22. // Right horizontal (steering)
  23. #define STEER_CHANNEL 1
  24. #define STEER_LEFT 1300
  25. #define STEER_RIGHT 1690
  26. #define STEER_NONE 1500
  27. #define STEER_DEAD_ZONE 30 // 10% of the range is dead zone
  28. // Right vertical (throttle)
  29. #define THROT_CHANNEL 2
  30. #define THROT_MAX 1940
  31. #define THROT_MIN 1160
  32. #define THROT_NONE 1510// Halfway range
  33. #define THROT_DEAD_ZONE 30 // approx 10% of the range is dead
  34. #define THROT_OFF 0 // Anything below this means the throttle switch (upper right) is off
  35. #define CH_4_MIN 0
  36. #define CH_4_MAX 0
  37. // Right knob
  38. #define LIGHT_CHANNEL 5
  39. #define LIGHT_MIN 990
  40. #define LIGHT_MAX 1990
  41. // Left knob
  42. #define SPEED_CHANNEL 6
  43. #define SPEED_MIN 1000
  44. #define SPEED_MAX 2000
  45. /////////////////////////////////////////////////////////////////////////
  46. // Output pins
  47. /////////////////////////////////////////////////////////////////////////
  48. #define LEFT_MOTOR_PIN 5
  49. #define LEFT_MOTOR_DIRECT_PIN 4
  50. #define RIGHT_MOTOR_PIN 6
  51. #define RIGHT_MOTOR_DIRECT_PIN 7