_PCINT.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #include <PinChangeInt.h>
  2. // PIN NAMING
  3. // For the Analog Input pins used as digital input pins, you can call them 14, 15, 16, etc.
  4. // or you can use A0, A1, A2, etc. (the Arduino code will properly recognize the symbolic names,
  5. // for example, pinMode(A0, INPUT_PULLUP);
  6. // For Arduino MEGA (AT2560-based), besides the regular pins and the A (analog) pins,
  7. // you have 4 more pins with defined names:
  8. // SS = 53
  9. // MOSI = 51
  10. // MISO = 50
  11. // SCK = 52
  12. // NOW CHOOSE PINS
  13. #if ! ( defined __AVR_ATmega2560__ || defined __AVR_ATmega1280__ || defined __AVR_ATmega1281__ || defined __AVR_ATmega2561__ || defined __AVR_ATmega640__ )
  14. #error "This sketch only works on chips in the ATmega2560 family."
  15. #endif
  16. #define FIRST_ANALOG_PIN 54
  17. #define TOTAL_PINS 69 //97 // 69 // But only 18 of them (not including RX0) are PinChangeInt-compatible
  18. // Don't use RX0 (Arduino pin 0) in this program- it won't work this is the
  19. // pin that Serial.print() uses!
  20. // See the Arduino and the chip documentation for more details.
  21. #define MYPIN1 ROTTARY_SW_clk // ROTTARY_SW_sw // ROTTARY_SW_sw // SS
  22. #define MYPIN2 ROTTARY_SW_dt // SCK
  23. #define MYPIN3 ROTTARY_SW_sw // A8 //ROTTARY_SW_sw // MOSI
  24. #define PIN3TEXT "ROTTARY_SW_sw " // This will say what MYPIN3 is, on the serial monitor
  25. volatile uint8_t latest_interrupted_pin;
  26. volatile uint8_t interrupt_count[TOTAL_PINS]={0}; // possible arduino pins
  27. volatile uint8_t pin3Count=0;
  28. // Do not use any Serial.print() in this function. Serial.print() uses interrupts, and is not compatible
  29. // with an interrupt routine...!
  30. void quicfunc() {
  31. latest_interrupted_pin=PCintPort::arduinoPin;
  32. interrupt_count[latest_interrupted_pin]++;
  33. };
  34. // You can assign any number of functions to different pins. How cool is that?
  35. void pin3func() {
  36. pin3Count++;
  37. Serial.println("pin3func TRIG");
  38. }
  39. uint8_t i;
  40. uint8_t currentPIN3Count=0;