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