![]() PCICR |= bit (digitalPinToPCICRbit (encoders. *ICRmaskPort |= bit (digitalPinToPCMSKbit (encoders. Volatile byte * ICRmaskPort = digitalPinToPCMSK (encoders. activate this pin-change interrupt bit (eg. ![]() whichInterrupt = digitalPinToPCICRbit (encoders. bBitMask = digitalPinToBitMask (encoders. aBitMask = digitalPinToBitMask (encoders. bPort = portInputRegister (digitalPinToPort (encoders. aPort = portInputRegister (digitalPinToPort (encoders. convert pin number to port, mask, etc. PCIFR |= bit (PCIF0) | bit (PCIF1) | bit (PCIF2) // clear any outstanding interrupts handle pin change interrupt for D0 to D7 here handle pin change interrupt for A0 to A5 here handle pin change interrupt for D8 to D13 here If ((encoderALast = HIGH) & (encoderA = LOW)) // end of if this is the right interrupt number Serial.println(val) // print it in serial monitorīoolean encoderA = digitalRead(encoderPinA) receive the direction for clockwise 1 and for counter clock wise -1 const int encoderPinA = 7 īoolean encoderALast = LOW // remember the previous pin state Any help appreciated.įollowing is the code. I'm supposed to get +1 for clockwise and -1 for counter-clockwise. I'm trying to detect the direction of rotation for an incremental rotary encoder.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |