rc_receiver_driving.ino 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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 100 // 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. /////////////////////////////////////////////////////////////////////////
  18. // Channel values
  19. /////////////////////////////////////////////////////////////////////////
  20. // Right horizontal (steering)
  21. #define STEER_CHANNEL 1
  22. #define STEER_LEFT 1300
  23. #define STEER_RIGHT 1690
  24. #define STEER_NONE 1500
  25. #define STEER_DEAD_ZONE 30 // 10% of the range is dead zone
  26. // Right vertical (throttle)
  27. #define THROT_CHANNEL 2
  28. #define THROT_MAX 1940
  29. #define THROT_MIN 1160
  30. #define THROT_NONE 1510// Halfway range
  31. #define THROT_DEAD_ZONE 30 // approx 10% of the range is dead
  32. #define THROT_OFF 0 // Anything below this means the throttle switch (upper right) is off
  33. #define CH_4_MIN 0
  34. #define CH_4_MAX 0
  35. // Right knob
  36. #define LIGHT_CHANNEL 5
  37. #define LIGHT_MIN 990
  38. #define LIGHT_MAX 1990
  39. // Left knob
  40. #define SPEED_CHANNEL 6
  41. #define SPEED_MIN 1000
  42. #define SPEED_MAX 2000
  43. /////////////////////////////////////////////////////////////////////////
  44. // Output pins
  45. /////////////////////////////////////////////////////////////////////////
  46. #define LEFT_MOTOR_PIN 5
  47. #define LEFT_MOTOR_DIRECT_PIN 4
  48. #define RIGHT_MOTOR_PIN 6
  49. #define RIGHT_MOTOR_DIRECT_PIN 7