pins.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #ifndef PINS_MODULE
  2. #define PINS_MODULE
  3. #import <Arduino.h>
  4. #include "definitions.h"
  5. struct PinStruct
  6. {
  7. #if defined(__AVR_ATmega328P__) || defined(__AVR_ATmega168__) // If Arduiono Uno is used
  8. #pragma message("Compiling airtrack for Arduino Uno - PWM pins has no effect")
  9. #define NO_EFFECT_PIN 13
  10. #define USE_PIN(PIN_NUM) NO_EFFECT_PIN
  11. #define ARDUINO_UNO
  12. #elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) // If Arduino Mega is used
  13. #pragma message("Compiling airtrack for Arduino Mega - Using PWM pins")
  14. #define USE_PIN(PIN_NUM) PIN_NUM
  15. #define ARDUINO_MEGA
  16. #else
  17. #warning "Unknown Arduino board type, PWM works might not work or conflict"
  18. #define USE_PIN(PIN_NUM) PIN_NUM
  19. #endif
  20. #ifdef ARDUINO_UNO
  21. // Pins configuration for arduino uno
  22. CONST_PIN_TYPE Sensor = 2;
  23. CONST_PIN_TYPE ActuatorPush = 4;
  24. CONST_PIN_TYPE ActuatorPull = 3;
  25. CONST_PIN_TYPE SolenoidLeft = 5;
  26. CONST_PIN_TYPE SolenoidRight = 8;
  27. CONST_PIN_TYPE LaneLight = 6;
  28. CONST_PIN_TYPE PeizoTone = 7;
  29. #else #if def ARDUINO_MEGA
  30. // Pins configuration for arduino mega
  31. CONST_PIN_TYPE Sensor = 38;
  32. CONST_PIN_TYPE ActuatorPush = 30;
  33. CONST_PIN_TYPE ActuatorPull = 32;
  34. // 26 and 28 are free
  35. CONST_PIN_TYPE SolenoidLeft = 22;
  36. CONST_PIN_TYPE SolenoidRight = 24;
  37. CONST_PIN_TYPE LaneLight = 27;
  38. CONST_PIN_TYPE LaneLight2 = A14;
  39. CONST_PIN_TYPE PeizoTone = 29;
  40. #endif #endif
  41. // Has no effect except on arduino mega
  42. CONST_PIN_TYPE PWM_CurrentLaneNum = USE_PIN(8);
  43. CONST_PIN_TYPE PWM_CorrectLaneNum = USE_PIN(8);
  44. CONST_PIN_TYPE PWM_LaneState = USE_PIN(4);
  45. CONST_PIN_TYPE PWM_PixyX = USE_PIN(8);
  46. CONST_PIN_TYPE PWM_PixyY = USE_PIN(8);
  47. CONST_PIN_TYPE PWM_PixyAngle = USE_PIN(8);
  48. CONST_PIN_TYPE PWM_LaneLed = USE_PIN(8);
  49. CONST_PIN_TYPE PWM_RotationDirection = USE_PIN(9);
  50. CONST_PIN_TYPE PWM_LickDirection = USE_PIN(10);
  51. CONST_PIN_TYPE PWM_DecisionResult = USE_PIN(11);
  52. CONST_PIN_TYPE PWM_RewardResult = USE_PIN(12);
  53. //CONST_PIN_TYPE PWM_RewardState = USE_PIN(13);
  54. CONST_PIN_TYPE PWM_PiezoAlarm = USE_PIN(44);
  55. CONST_PIN_TYPE PWM_Solenoid = USE_PIN(45);
  56. CONST_PIN_TYPE PWM_Actuator = USE_PIN(46);
  57. CONST_PIN_TYPE OutOfFirstLane = USE_PIN(39);
  58. CONST_PIN_TYPE InCorrecctLane = USE_PIN(41);
  59. } Pins;
  60. #endif